#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*/ die(char *);
scalar_t__ strcmp(char *, char *);
int main() {
  char buf[100] = "fnord";
  char buf2[100] = "fnort";
  if (strcmp(buf, buf))
    die("strcmp said a != a");
  if (strcmp(buf, buf2) >= 0)
    die("strcmp said fnord > fnort");
  if (strcmp(buf2, buf) <= 0)
    die("strcmp said fnort < fnord");
  if (strcmp(buf + 1, buf2 + 1) >= 0)
    die("unaligned strcmp is broken 1");
  if (strcmp(buf + 2, buf2 + 2) >= 0)
    die("unaligned strcmp is broken 2");
  if (strcmp(buf + 3, buf2 + 3) >= 0)
    die("unaligned strcmp is broken 3");
  if (strcmp("mäh", "meh") < 0)
    die("strcmp uses signed arithmetic");
  if (strcmp("foo", "foobar") >= 0)
    die("prefix handling broken in strcmp 1");
  if (strcmp("foobar", "foo") <= 0)
    die("prefix handling broken in strcmp 2");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1030 <memset@plt>
movb   $0x66,-0x70(%rbp)
movb   $0x6e,-0x6f(%rbp)
movb   $0x6f,-0x6e(%rbp)
movb   $0x72,-0x6d(%rbp)
movb   $0x64,-0x6c(%rbp)
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1030 <memset@plt>
movb   $0x66,-0xe0(%rbp)
movb   $0x6e,-0xdf(%rbp)
movb   $0x6f,-0xde(%rbp)
movb   $0x72,-0xdd(%rbp)
movb   $0x74,-0xdc(%rbp)
lea    -0x70(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11bf <main+0x8f>
lea    0xe46(%rip),%rdi
call   1050 <die@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jl     11e5 <main+0xb5>
lea    0xe33(%rip),%rdi
call   1050 <die@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jg     120b <main+0xdb>
lea    0xe27(%rip),%rdi
call   1050 <die@plt>
lea    -0x70(%rbp),%rdi
add    $0x1,%rdi
lea    -0xe0(%rbp),%rsi
add    $0x1,%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jl     1239 <main+0x109>
lea    0xe13(%rip),%rdi
call   1050 <die@plt>
lea    -0x70(%rbp),%rdi
add    $0x2,%rdi
lea    -0xe0(%rbp),%rsi
add    $0x2,%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jl     1267 <main+0x137>
lea    0xe02(%rip),%rdi
call   1050 <die@plt>
lea    -0x70(%rbp),%rdi
add    $0x3,%rdi
lea    -0xe0(%rbp),%rsi
add    $0x3,%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jl     1295 <main+0x165>
lea    0xdf1(%rip),%rdi
call   1050 <die@plt>
lea    0xe02(%rip),%rdi
lea    0xe00(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jge    12be <main+0x18e>
lea    0xdee(%rip),%rdi
call   1050 <die@plt>
lea    0xe00(%rip),%rdi
lea    0xdfd(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jl     12e7 <main+0x1b7>
lea    0xdee(%rip),%rdi
call   1050 <die@plt>
lea    0xddb(%rip),%rdi
lea    0xdd0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jg     1310 <main+0x1e0>
lea    0xde8(%rip),%rdi
call   1050 <die@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x60(%rsp)
movl   $0x726f6e66,(%rsp)
movb   $0x64,0x4(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movl   $0x0,0xd0(%rsp)
movl   $0x726f6e66,0x70(%rsp)
72
movb   $0x74,0x74(%rsp)
mov    %rsp,%rdi
mov    %rdi,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11c5 <main+0xa5>
lea    0xe40(%rip),%rdi
call   1040 <die@plt>
mov    %rsp,%rdi
lea    0x70(%rsp),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
js     11e3 <main+0xc3>
lea    0xe35(%rip),%rdi
call   1040 <die@plt>
lea    0x1(%rsp),%r15
lea    0x71(%rsp),%r14
lea    0x70(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jg     120b <main+0xeb>
lea    0xe27(%rip),%rdi
call   1040 <die@plt>
lea    0x2(%rsp),%r13
lea    0x72(%rsp),%r12
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
js     1231 <main+0x111>
lea    0xe1b(%rip),%rdi
call   1040 <die@plt>
lea    0x3(%rsp),%rbx
lea    0x73(%rsp),%r14
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
js     1257 <main+0x137>
lea    0xe12(%rip),%rdi
call   1040 <die@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
js     1273 <main+0x153>
lea    0xe13(%rip),%rdi
call   1040 <die@plt>
lea    0xe24(%rip),%rdi
lea    0xe22(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jns    1297 <main+0x177>
lea    0xe15(%rip),%rdi
call   1040 <die@plt>
lea    0xe27(%rip),%rdi
lea    0xe24(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
js     12bb <main+0x19b>
lea    0xe1a(%rip),%rdi
call   1040 <die@plt>
lea    0xe07(%rip),%rdi
lea    0xdfc(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jg     12df <main+0x1bf>
lea    0xe19(%rip),%rdi
call   1040 <die@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"strcmp said a != a\00"
@.str.1 = [26 x i8] c"strcmp said fnord > fnort\00"
@.str.2 = [26 x i8] c"strcmp said fnort < fnord\00"
@.str.3 = [29 x i8] c"unaligned strcmp is broken 1\00"
@.str.4 = [29 x i8] c"unaligned strcmp is broken 2\00"
@.str.5 = [29 x i8] c"unaligned strcmp is broken 3\00"
@.str.6 = [5 x i8] c"m\C3\A4h\00"
@.str.7 = [4 x i8] c"meh\00"
@.str.8 = [30 x i8] c"strcmp uses signed arithmetic\00"
@.str.9 = [4 x i8] c"foo\00"
@.str.10 = [7 x i8] c"foobar\00"
@.str.11 = [35 x i8] c"prefix handling broken in strcmp 1\00"
@.str.12 = [35 x i8] c"prefix handling broken in strcmp 2\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
store i32 0, i32* %1
%4 = bitcast [100 x i8]* %2 to i8*
%5 = bitcast i8* %4 to [100 x i8]*
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i32 0, i32 0
store i8 102, i8* %6
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i32 0, i32 1
store i8 110, i8* %7
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i32 0, i32 2
store i8 111, i8* %8
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i32 0, i32 3
store i8 114, i8* %9
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i32 0, i32 4
store i8 100, i8* %10
%11 = bitcast [100 x i8]* %3 to i8*
%12 = bitcast i8* %11 to [100 x i8]*
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i32 0, i32 0
store i8 102, i8* %13
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i32 0, i32 1
store i8 110, i8* %14
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i32 0, i32 2
store i8 111, i8* %15
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i32 0, i32 3
store i8 114, i8* %16
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i32 0, i32 4
store i8 116, i8* %17
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%20 = call i64 @strcmp(i8* %18, i8* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %0
%23 = call i32 @die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %0
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%27 = call i64 @strcmp(i8* %25, i8* %26)
%28 = icmp sge i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29, %24
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%34 = call i64 @strcmp(i8* %32, i8* %33)
%35 = icmp sle i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = call i32 @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36, %31
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%40 = getelementptr inbounds i8, i8* %39, i64 1
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = call i64 @strcmp(i8* %40, i8* %42)
%44 = icmp sge i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %38
%46 = call i32 @die(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %45, %38
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%49 = getelementptr inbounds i8, i8* %48, i64 2
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%51 = getelementptr inbounds i8, i8* %50, i64 2
%52 = call i64 @strcmp(i8* %49, i8* %51)
%53 = icmp sge i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %47
%55 = call i32 @die(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %56
56: ; preds = %54, %47
%57 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%58 = getelementptr inbounds i8, i8* %57, i64 3
%59 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%60 = getelementptr inbounds i8, i8* %59, i64 3
%61 = call i64 @strcmp(i8* %58, i8* %60)
%62 = icmp sge i64 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %56
%64 = call i32 @die(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %65
65: ; preds = %63, %56
%66 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%67 = icmp slt i64 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %65
%69 = call i32 @die(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
br label %70
70: ; preds = %68, %65
%71 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%72 = icmp sge i64 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %70
%74 = call i32 @die(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.11, i64 0, i64 0))
br label %75
75: ; preds = %73, %70
%76 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%77 = icmp sle i64 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %75
%79 = call i32 @die(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.12, i64 0, i64 0))
br label %80
80: ; preds = %78, %75
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"strcmp said a != a\00"
@.str.1 = [26 x i8] c"strcmp said fnord > fnort\00"
@.str.2 = [26 x i8] c"strcmp said fnort < fnord\00"
@.str.3 = [29 x i8] c"unaligned strcmp is broken 1\00"
@.str.4 = [29 x i8] c"unaligned strcmp is broken 2\00"
@.str.5 = [29 x i8] c"unaligned strcmp is broken 3\00"
@.str.6 = [5 x i8] c"m\C3\A4h\00"
@.str.7 = [4 x i8] c"meh\00"
@.str.8 = [30 x i8] c"strcmp uses signed arithmetic\00"
@.str.9 = [4 x i8] c"foo\00"
@.str.10 = [7 x i8] c"foobar\00"
@.str.11 = [35 x i8] c"prefix handling broken in strcmp 1\00"
@.str.12 = [35 x i8] c"prefix handling broken in strcmp 2\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
store i8 102, i8* %3
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 1
store i8 110, i8* %4
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 2
store i8 111, i8* %5
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 3
store i8 114, i8* %6
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 4
store i8 100, i8* %7
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
store i8 102, i8* %8
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 1
store i8 110, i8* %9
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 2
store i8 111, i8* %10
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 3
store i8 114, i8* %11
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 4
store i8 116, i8* %12
%13 = call i64 @strcmp(i8* %3, i8* %3)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %0
%16 = call i32 @die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %0
%18 = call i64 @strcmp(i8* %3, i8* %8)
%19 = icmp sgt i64 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = call i64 @strcmp(i8* %8, i8* %3)
%24 = icmp slt i64 %23, 1
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
%28 = call i64 @strcmp(i8* %4, i8* %9)
%29 = icmp sgt i64 %28, -1
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @die(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
%33 = call i64 @strcmp(i8* %5, i8* %10)
%34 = icmp sgt i64 %33, -1
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call i32 @die(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %37
37: ; preds = %35, %32
%38 = call i64 @strcmp(i8* %6, i8* %11)
%39 = icmp sgt i64 %38, -1
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 @die(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %42
42: ; preds = %40, %37
%43 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%44 = icmp slt i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 @die(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
br label %47
47: ; preds = %45, %42
%48 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%49 = icmp sgt i64 %48, -1
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 @die(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.11, i64 0, i64 0))
br label %52
52: ; preds = %50, %47
%53 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%54 = icmp slt i64 %53, 1
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = call i32 @die(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.12, i64 0, i64 0))
br label %57
57: ; preds = %55, %52
ret i32 0
}