#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 mystrcmp(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char s1[] = "ACB2";
  char s2[] = "ABCD";
  int i = 0;
  i = mystrcmp(s1, s2);
  if (i < 0) {
    printf("%s\n", s1);
  } else if (i > 0) {
    printf("%s\n", s2);
  } else {
    printf("%s\n", s1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xec6(%rip),%al
mov    %al,-0x5(%rbp)
mov    0xebe(%rip),%eax
mov    %eax,-0xe(%rbp)
mov    0xeb9(%rip),%al
mov    %al,-0xa(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x9(%rbp),%rdi
lea    -0xe(%rbp),%rsi
call   1030 <mystrcmp@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1189 <main+0x69>
lea    -0x9(%rbp),%rsi
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
jmp    11bd <main+0x9d>
cmpl   $0x0,-0x14(%rbp)
jle    11a8 <main+0x88>
lea    -0xe(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
jmp    11b8 <main+0x98>
lea    -0x9(%rbp),%rsi
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
jmp    11bd <main+0x9d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movb   $0x0,0x14(%rsp)
movl   $0x32424341,0x10(%rsp)
32
movb   $0x0,0xc(%rsp)
movl   $0x44434241,0x8(%rsp)
44
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <mystrcmp@plt>
test   %eax,%eax
cmovle %r14,%rbx
lea    0xea7(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.s1 = [5 x i8] c"ACB2\00"
@__const.main.s2 = [5 x i8] c"ABCD\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = alloca [5 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [5 x i8]* %2 to i8*
%6 = bitcast [5 x i8]* %3 to i8*
store i32 0, i32* %4
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%9 = call i32 @mystrcmp(i8* %7, i8* %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %25
15: ; preds = %0
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %24
21: ; preds = %15
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %21, %18
br label %25
25: ; preds = %24, %12
ret i32 0
}

LLVM IR (-O2):
@__const.main.s1 = [5 x i8] c"ACB2\00"
@__const.main.s2 = [5 x i8] c"ABCD\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = call i32 @mystrcmp(i8* %3, i8* %4)
%6 = icmp slt i32 %5, 1
%7 = select i1 %6, i8* %3, i8* %4
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
ret i32 0
}