#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 /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int main() {
  char str1[] = "cat", str2[] = "dog", str3[] = "cow", str4[] = "antelope";
  char name1[30 + 1], name2[30 + 1];
  printf("strcmp() Examples\n\n");
  if (strcmp(str1, str2) < 0)
    printf("%s appears before %s.\n\n", str1, str2);
  if (strcmp(str2, str3) > 0)
    printf("%s appears after %s.\n\n", str2, str3);
  if (strcmp(str1, str4) > 0)
    printf("%s appears after %s.\n\n", str1, str4);
  if (strcmp(str3, "cow") == 0)
    printf("These two strings are the same.\n\n");
  printf("Enter first name (no spaces): ");
  scanf("%s", name1);
  printf("Enter second name (no spaces): ");
  scanf("%s", name2);
  if (strcmp(name1, name2) < 0)
    printf("'%s' appears before '%s'.\n\n", name1, name2);
  else if (strcmp(name1, name2) == 0)
    printf("These strings are the same.\n\n");
  else
    printf("'%s' appears after '%s'.\n\n", name1, name2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xebb(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xeb6(%rip),%eax
mov    %eax,-0xc(%rbp)
mov    0xeb1(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x19(%rbp)
mov    0xea9(%rip),%al
mov    %al,-0x11(%rbp)
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jge    11a9 <main+0x79>
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jle    11d6 <main+0xa6>
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x8(%rbp),%rdi
lea    -0x19(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jle    1203 <main+0xd3>
lea    -0x8(%rbp),%rsi
lea    -0x19(%rbp),%rdx
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
lea    0xdfa(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    122b <main+0xfb>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe55(%rip),%rdi
call   1050 <scanf@plt>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rsi
lea    0xe37(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jge    1299 <main+0x169>
lea    -0x40(%rbp),%rsi
lea    -0x60(%rbp),%rdx
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12de <main+0x1ae>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12c3 <main+0x193>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d9 <main+0x1a9>
lea    -0x40(%rbp),%rsi
lea    -0x60(%rbp),%rdx
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12de <main+0x1ae>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
movl   $0x746163,0x8(%rsp)
movl   $0x676f64,0x4(%rsp)
movl   $0x776f63,0xc(%rsp)
movabs $0x65706f6c65746e61,%rax
6f 70 65
mov    %rax,0x10(%rsp)
movb   $0x0,0x18(%rsp)
lea    0xf39(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jns    11ad <main+0x6d>
lea    0xe6d(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jle    11d9 <main+0x99>
lea    0xe59(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jle    1205 <main+0xc5>
lea    0xe2d(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe2c(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1227 <main+0xe7>
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xe0e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe1f(%rip),%r15
lea    0x40(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
lea    0xe0b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x20(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jns    1283 <main+0x143>
lea    0xdfd(%rip),%rdi
jmp    129e <main+0x15e>
lea    0x40(%rsp),%rdi
lea    0x20(%rsp),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12b1 <main+0x171>
lea    0xdfc(%rip),%rdi
lea    0x40(%rsp),%rsi
lea    0x20(%rsp),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12bd <main+0x17d>
lea    0xe10(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.str1 = [4 x i8] c"cat\00"
@__const.main.str2 = [4 x i8] c"dog\00"
@__const.main.str3 = [4 x i8] c"cow\00"
@__const.main.str4 = [9 x i8] c"antelope\00"
@.str = [20 x i8] c"strcmp() Examples\0A\0A\00"
@.str.1 = [24 x i8] c"%s appears before %s.\0A\0A\00"
@.str.2 = [23 x i8] c"%s appears after %s.\0A\0A\00"
@.str.3 = [4 x i8] c"cow\00"
@.str.4 = [34 x i8] c"These two strings are the same.\0A\0A\00"
@.str.5 = [31 x i8] c"Enter first name (no spaces): \00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [32 x i8] c"Enter second name (no spaces): \00"
@.str.8 = [28 x i8] c"'%s' appears before '%s'.\0A\0A\00"
@.str.9 = [30 x i8] c"These strings are the same.\0A\0A\00"
@.str.10 = [27 x i8] c"'%s' appears after '%s'.\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i8]
%3 = alloca [4 x i8]
%4 = alloca [4 x i8]
%5 = alloca [9 x i8]
%6 = alloca [31 x i8]
%7 = alloca [31 x i8]
store i32 0, i32* %1
%8 = bitcast [4 x i8]* %2 to i8*
%9 = bitcast [4 x i8]* %3 to i8*
%10 = bitcast [4 x i8]* %4 to i8*
%11 = bitcast [9 x i8]* %5 to i8*
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%15 = call i64 @strcmp(i8* %13, i8* %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %0
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %19)
br label %21
21: ; preds = %17, %0
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%24 = call i64 @strcmp(i8* %22, i8* %23)
%25 = icmp sgt i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %27, i8* %28)
br label %30
30: ; preds = %26, %21
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%32 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%33 = call i64 @strcmp(i8* %31, i8* %32)
%34 = icmp sgt i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %30
%36 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%37 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %36, i8* %37)
br label %39
39: ; preds = %35, %30
%40 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
br label %45
45: ; preds = %43, %39
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%47 = getelementptr inbounds [31 x i8], [31 x i8]* %6, i64 0, i64 0
%48 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%50 = getelementptr inbounds [31 x i8], [31 x i8]* %7, i64 0, i64 0
%51 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %50)
%52 = getelementptr inbounds [31 x i8], [31 x i8]* %6, i64 0, i64 0
%53 = getelementptr inbounds [31 x i8], [31 x i8]* %7, i64 0, i64 0
%54 = call i64 @strcmp(i8* %52, i8* %53)
%55 = icmp slt i64 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %45
%57 = getelementptr inbounds [31 x i8], [31 x i8]* %6, i64 0, i64 0
%58 = getelementptr inbounds [31 x i8], [31 x i8]* %7, i64 0, i64 0
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i8* %57, i8* %58)
br label %72
60: ; preds = %45
%61 = getelementptr inbounds [31 x i8], [31 x i8]* %6, i64 0, i64 0
%62 = getelementptr inbounds [31 x i8], [31 x i8]* %7, i64 0, i64 0
%63 = call i64 @strcmp(i8* %61, i8* %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %60
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0))
br label %71
67: ; preds = %60
%68 = getelementptr inbounds [31 x i8], [31 x i8]* %6, i64 0, i64 0
%69 = getelementptr inbounds [31 x i8], [31 x i8]* %7, i64 0, i64 0
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i8* %68, i8* %69)
br label %71
71: ; preds = %67, %65
br label %72
72: ; preds = %71, %56
ret i32 0
}

LLVM IR (-O2):
@__const.main.str4 = [9 x i8] c"antelope\00"
@.str.1 = [24 x i8] c"%s appears before %s.\0A\0A\00"
@.str.2 = [23 x i8] c"%s appears after %s.\0A\0A\00"
@.str.3 = [4 x i8] c"cow\00"
@.str.5 = [31 x i8] c"Enter first name (no spaces): \00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [32 x i8] c"Enter second name (no spaces): \00"
@.str.8 = [28 x i8] c"'%s' appears before '%s'.\0A\0A\00"
@.str.10 = [27 x i8] c"'%s' appears after '%s'.\0A\0A\00"
@str = [19 x i8] c"strcmp() Examples\0A\00"
@str.11 = [29 x i8] c"These strings are the same.\0A\00"
@str.12 = [33 x i8] c"These two strings are the same.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [9 x i8]
%5 = alloca [31 x i8]
%6 = alloca [31 x i8]
%7 = bitcast i32* %1 to i8*
store i32 7627107, i32* %1
%8 = bitcast i32* %2 to i8*
store i32 6778724, i32* %2
%9 = bitcast i32* %3 to i8*
store i32 7827299, i32* %3
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [31 x i8], [31 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [31 x i8], [31 x i8]* %6, i64 0, i64 0
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%14 = call i64 @strcmp(i8* %7, i8* %8)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
br label %18
18: ; preds = %16, %0
%19 = call i64 @strcmp(i8* %8, i8* %9)
%20 = icmp sgt i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3)
br label %23
23: ; preds = %21, %18
%24 = call i64 @strcmp(i8* %7, i8* %10)
%25 = icmp sgt i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32* %1, i8* %10)
br label %28
28: ; preds = %26, %23
%29 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.12, i64 0, i64 0))
br label %33
33: ; preds = %31, %28
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %11)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %12)
%38 = call i64 @strcmp(i8* %11, i8* %12)
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %33
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i8* %11, i8* %12)
br label %49
42: ; preds = %33
%43 = call i64 @strcmp(i8* %11, i8* %12)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.11, i64 0, i64 0))
br label %49
47: ; preds = %42
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i8* %11, i8* %12)
br label %49
49: ; preds = %45, %47, %40
ret i32 0
}