#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 chmin(char, char);
int /*<<< orphan*/ printf(char *, char, char, char, int);
void chmin_test() {
  char a[] = {'a', 'a', 'b', (char)0, (char)127};
  char b[] = {'b', 'a', 'a', 'e', 'e'};
  char e[] = {'a', 'a', 'a', (char)0, 'e'};
  for (int i = 0; i < 5; i++) {
    if (chmin(a[i], b[i]) != e[i]) {
      printf("Error!\n a: %c\t b: %c\n expected: %c\t actual: %c\n", a[i], b[i],
             e[i], chmin(a[i], b[i]));
    }
  }
}


x86 assembly (clang, -O0):
<chmin_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed2(%rip),%eax
mov    %eax,-0x5(%rbp)
mov    0xecd(%rip),%al
mov    %al,-0x1(%rbp)
mov    0xec5(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xec0(%rip),%al
mov    %al,-0x6(%rbp)
mov    0xeb8(%rip),%eax
mov    %eax,-0xf(%rbp)
mov    0xeb3(%rip),%al
mov    %al,-0xb(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    1207 <chmin_test+0xe7>
movslq -0x14(%rbp),%rax
mov    -0x5(%rbp,%rax,1),%cl
movslq -0x14(%rbp),%rax
movsbl %cl,%edi
movsbl -0xa(%rbp,%rax,1),%esi
call   1040 <chmin@plt>
movslq -0x14(%rbp),%rcx
movsbl -0xf(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11f4 <chmin_test+0xd4>
movslq -0x14(%rbp),%rax
mov    -0x5(%rbp,%rax,1),%al
mov    %al,-0x17(%rbp)
movslq -0x14(%rbp),%rax
mov    -0xa(%rbp,%rax,1),%al
mov    %al,-0x16(%rbp)
movslq -0x14(%rbp),%rax
mov    -0xf(%rbp,%rax,1),%al
mov    %al,-0x15(%rbp)
movslq -0x14(%rbp),%rax
mov    -0x5(%rbp,%rax,1),%cl
movslq -0x14(%rbp),%rax
movsbl %cl,%edi
movsbl -0xa(%rbp,%rax,1),%esi
call   1040 <chmin@plt>
mov    -0x17(%rbp),%dl
mov    -0x16(%rbp),%cl
mov    %eax,%r8d
mov    -0x15(%rbp),%al
lea    0xe29(%rip),%rdi
movsbl %dl,%esi
movsbl %cl,%edx
movsbl %al,%ecx
call   1030 <printf@plt>
jmp    11f9 <chmin_test+0xd9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1165 <chmin_test+0x45>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chmin_test>:
push   %rax
mov    $0x61,%edi
mov    $0x62,%esi
call   1040 <chmin@plt>
cmp    $0x61,%eax
je     1162 <chmin_test+0x42>
mov    $0x61,%edi
mov    $0x62,%esi
call   1040 <chmin@plt>
lea    0xeb5(%rip),%rdi
mov    $0x61,%esi
mov    $0x62,%edx
mov    $0x61,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    $0x61,%edi
mov    $0x61,%esi
call   1040 <chmin@plt>
cmp    $0x61,%eax
je     11a3 <chmin_test+0x83>
mov    $0x61,%edi
mov    $0x61,%esi
call   1040 <chmin@plt>
lea    0xe74(%rip),%rdi
mov    $0x61,%esi
mov    $0x61,%edx
mov    $0x61,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    $0x62,%edi
mov    $0x61,%esi
call   1040 <chmin@plt>
cmp    $0x61,%eax
je     11e4 <chmin_test+0xc4>
mov    $0x62,%edi
mov    $0x61,%esi
call   1040 <chmin@plt>
lea    0xe33(%rip),%rdi
mov    $0x62,%esi
mov    $0x61,%edx
mov    $0x61,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
xor    %edi,%edi
mov    $0x65,%esi
call   1040 <chmin@plt>
test   %eax,%eax
je     1218 <chmin_test+0xf8>
xor    %edi,%edi
mov    $0x65,%esi
call   1040 <chmin@plt>
lea    0xdf9(%rip),%rdi
xor    %esi,%esi
mov    $0x65,%edx
xor    %ecx,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    $0x7f,%edi
mov    $0x65,%esi
call   1040 <chmin@plt>
cmp    $0x65,%eax
jne    122e <chmin_test+0x10e>
pop    %rax
ret
mov    $0x7f,%edi
mov    $0x65,%esi
call   1040 <chmin@plt>
lea    0xdbc(%rip),%rdi
mov    $0x7f,%esi
mov    $0x65,%edx
mov    $0x65,%ecx
mov    %eax,%r8d
pop    %rax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@__const.chmin_test.a = [5 x i8] c"aab\00\7F"
@__const.chmin_test.b = [5 x i8] c"baaee"
@__const.chmin_test.e = [5 x i8] c"aaa\00e"
@.str = [48 x i8] c"Error!\0A a: %c\09 b: %c\0A expected: %c\09 actual: %c\0A\00"
define void @chmin_test() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = alloca [5 x i8]
%4 = alloca i32
%5 = bitcast [5 x i8]* %1 to i8*
%6 = bitcast [5 x i8]* %2 to i8*
%7 = bitcast [5 x i8]* %3 to i8*
store i32 0, i32* %4
br label %8
8: ; preds = %51, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %54
11: ; preds = %8
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = call i32 @chmin(i8 signext %15, i8 signext %19)
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %20, %25
br i1 %26, label %27, label %50
27: ; preds = %11
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = call i32 @chmin(i8 signext %43, i8 signext %47)
%49 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8 signext %31, i8 signext %35, i8 signext %39, i32 %48)
br label %50
50: ; preds = %27, %11
br label %51
51: ; preds = %50
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
br label %8
54: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [48 x i8] c"Error!\0A a: %c\09 b: %c\0A expected: %c\09 actual: %c\0A\00"
define void @chmin_test() {
%1 = tail call i32 @chmin(i8 signext 97, i8 signext 98)
%2 = icmp eq i32 %1, 97
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = tail call i32 @chmin(i8 signext 97, i8 signext 98)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8 signext 97, i8 signext 98, i8 signext 97, i32 %4)
br label %6
6: ; preds = %0, %3
%7 = tail call i32 @chmin(i8 signext 97, i8 signext 97)
%8 = icmp eq i32 %7, 97
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = tail call i32 @chmin(i8 signext 97, i8 signext 97)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8 signext 97, i8 signext 97, i8 signext 97, i32 %10)
br label %12
12: ; preds = %9, %6
%13 = tail call i32 @chmin(i8 signext 98, i8 signext 97)
%14 = icmp eq i32 %13, 97
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i32 @chmin(i8 signext 98, i8 signext 97)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8 signext 98, i8 signext 97, i8 signext 97, i32 %16)
br label %18
18: ; preds = %15, %12
%19 = tail call i32 @chmin(i8 signext 0, i8 signext 101)
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = tail call i32 @chmin(i8 signext 0, i8 signext 101)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8 signext 0, i8 signext 101, i8 signext 0, i32 %22)
br label %24
24: ; preds = %21, %18
%25 = tail call i32 @chmin(i8 signext 127, i8 signext 101)
%26 = icmp eq i32 %25, 101
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = tail call i32 @chmin(i8 signext 127, i8 signext 101)
%29 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8 signext 127, i8 signext 101, i8 signext 101, i32 %28)
br label %30
30: ; preds = %27, %24
ret void
}