#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*/ printf(char *, int);
int main(void) {
  int my_str_cmp(const char s1[], const char s2[]);
  const char str_a[] = "string compare test";
  const char str_b[] = "string";
  printf("%i\n", my_str_cmp(str_a, str_b));
  printf("%i\n", my_str_cmp(str_a, str_a));
  printf("%i\n", my_str_cmp(str_b, "string"));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xecc(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xec7(%rip),%eax
mov    %eax,-0x27(%rbp)
mov    0xec1(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xeb9(%rip),%al
mov    %al,-0x21(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x27(%rbp),%rsi
call   1040 <my_str_cmp@plt>
mov    %eax,%esi
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <my_str_cmp@plt>
mov    %eax,%esi
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
lea    -0x27(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1040 <my_str_cmp@plt>
mov    %eax,%esi
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movaps 0xece(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x747365,0x20(%rsp)
movl   $0x676e69,0xb(%rsp)
movl   $0x69727473,0x8(%rsp)
69
lea    0xec2(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <my_str_cmp@plt>
lea    0xea2(%rip),%r12
mov    %r12,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1040 <my_str_cmp@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <my_str_cmp@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.str_a = [20 x i8] c"string compare test\00"
@__const.main.str_b = [7 x i8] c"string\00"
@.str = [4 x i8] c"%i\0A\00"
@.str.1 = [7 x i8] c"string\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [7 x i8]
%3 = bitcast [20 x i8]* %1 to i8*
%4 = bitcast [7 x i8]* %2 to i8*
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%7 = call i32 @my_str_cmp(i8* %5, i8* %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%11 = call i32 @my_str_cmp(i8* %9, i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%14 = call i32 @my_str_cmp(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
ret i32 0
}

LLVM IR (-O2):
@__const.main.str_a = [20 x i8] c"string compare test\00"
@.str = [4 x i8] c"%i\0A\00"
@.str.1 = [7 x i8] c"string\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [7 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%5 = call i32 @my_str_cmp(i8* %3, i8* %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @my_str_cmp(i8* %3, i8* %3)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @my_str_cmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
ret i32 0
}