#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 mycmp(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main(int argc, const char *argv[]) {
  char s1[] = "abc";
  char s2[] = "abc ";
  printf("%d\n", strcmp(s1, s2));
  printf("%d\n", mycmp(s1, s2));
  if (strcmp(s1, s2) == 0) {
    printf("s1 = s2");
  } else {
    printf("s1 != s2");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb4(%rip),%eax
mov    %eax,-0x14(%rbp)
mov    0xeaf(%rip),%eax
mov    %eax,-0x19(%rbp)
mov    0xeaa(%rip),%al
mov    %al,-0x15(%rbp)
lea    -0x14(%rbp),%rdi
lea    -0x19(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rsi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x14(%rbp),%rdi
lea    -0x19(%rbp),%rsi
call   1050 <mycmp@plt>
mov    %eax,%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x14(%rbp),%rdi
lea    -0x19(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c6 <main+0x96>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d4 <main+0xa4>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x636261,0xc(%rsp)
movb   $0x0,0x8(%rsp)
movl   $0x20636261,0x4(%rsp)
20
lea    0xc(%rsp),%r15
lea    0x4(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
lea    0xe9b(%rip),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <mycmp@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
lea    0xe66(%rip),%rax
lea    0xe67(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.main.s2 = [5 x i8] c"abc \00"
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [8 x i8] c"s1 = s2\00"
@.str.2 = [9 x i8] c"s1 != s2\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [5 x i8]
%5 = bitcast i32* %3 to i8*
store i32 6513249, i32* %3
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%7 = call i64 @strcmp(i8* %5, i8* %6)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %7)
%9 = call i32 @mycmp(i8* %5, i8* %6)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i64 @strcmp(i8* %5, i8* %6)
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %13)
ret i32 0
}