#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strdup(char *);
scalar_t__ strlen(char *);
scalar_t__ strncmp(char *, char *, scalar_t__);
char *strtoupper(int /*<<< orphan*/);
int test_strtoupper(char *in, char *out) {
  char *test;
  printf("   strtoupper( '%s', '%s') ", in, out);
  test = strtoupper(strdup(in));
  printf(" = '%s' ", test);
  if (strlen(test) == strlen(out)) {
    if (strncmp(test, out, strlen(out)) == 0) {
      printf("passed\n");
      free(test);
      return (0);
    }
  }
  printf("failed\n");
  free(test);
  return (1);
}


x86 assembly (clang, -O0):
<test_strtoupper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <strdup@plt>
mov    %eax,%edi
call   1050 <strtoupper@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jne    122d <test_strtoupper+0xcd>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %rax,%rdx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1228 <test_strtoupper+0xc8>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    124b <test_strtoupper+0xeb>
jmp    122d <test_strtoupper+0xcd>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strtoupper>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xe7c(%rip),%rdi
xor    %r14d,%r14d
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1090 <strdup@plt>
mov    %eax,%edi
call   1060 <strtoupper@plt>
mov    %rax,%rbx
lea    0xe6f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %rax,%rbp
mov    %r15,%rdi
call   1070 <strlen@plt>
cmp    %rax,%rbp
jne    11e2 <test_strtoupper+0x72>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1040 <strncmp@plt>
test   %rax,%rax
je     11f1 <test_strtoupper+0x81>
mov    $0x1,%r14d
lea    0xe36(%rip),%rdi
jmp    11f8 <test_strtoupper+0x88>
lea    0xe34(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c" strtoupper( '%s', '%s') \00"
@.str.1 = [9 x i8] c" = '%s' \00"
@.str.2 = [8 x i8] c"passed\0A\00"
@.str.3 = [8 x i8] c"failed\0A\00"
define i32 @test_strtoupper(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8)
%10 = load i8*, i8** %4
%11 = call i32 @strdup(i8* %10)
%12 = call i8* @strtoupper(i32 %11)
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %6
%16 = call i64 @strlen(i8* %15)
%17 = load i8*, i8** %5
%18 = call i64 @strlen(i8* %17)
%19 = icmp eq i64 %16, %18
br i1 %19, label %20, label %32
20: ; preds = %2
%21 = load i8*, i8** %6
%22 = load i8*, i8** %5
%23 = load i8*, i8** %5
%24 = call i64 @strlen(i8* %23)
%25 = call i64 @strncmp(i8* %21, i8* %22, i64 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %20
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%29 = load i8*, i8** %6
%30 = call i32 @free(i8* %29)
store i32 0, i32* %3
br label %36
31: ; preds = %20
br label %32
32: ; preds = %31, %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%34 = load i8*, i8** %6
%35 = call i32 @free(i8* %34)
store i32 1, i32* %3
br label %36
36: ; preds = %32, %27
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [28 x i8] c" strtoupper( '%s', '%s') \00"
@.str.1 = [9 x i8] c" = '%s' \00"
@str = [7 x i8] c"failed\00"
@str.4 = [7 x i8] c"passed\00"
define i32 @test_strtoupper(i8* %0, i8* %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%4 = tail call i32 @strdup(i8* %0)
%5 = tail call i8* @strtoupper(i32 %4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %5)
%8 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = tail call i64 @strncmp(i8* %5, i8* %1, i64 %7)
%12 = icmp eq i64 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %10, %2
br label %14
14: ; preds = %10, %13
%15 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0), %13 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.4, i64 0, i64 0), %10 ]
%16 = phi i32 [ 1, %13 ], [ 0, %10 ]
%17 = tail call i32 @puts(i8* dereferenceable(1) %15)
%18 = tail call i32 @free(i8* %5)
ret i32 %16
}