#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 strcmp(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  char *string1 = argv[1];
  char *string2 = argv[2];
  int res = 0, i = 0, trigger = 0;
  printf("String 1: %s\n", string1);
  printf("String 2: %s\n", string2);
  int str1length = 0;
  int str2length = 0;
  str1length = strlen(string1);
  str2length = strlen(string2);
  if (str1length > str2length) {
    printf("Our result: The strings are different!\n");
  } else if (str1length < str2length) {
    printf("Our result: The strings are different!\n");
  } else {
    while (string1[i] != '\0') {
      if ((string1[i] != string2[i]) && trigger == 0) {
        trigger = 1;
      }
      i++;
    }
    if (trigger == 1) {
      printf("Our result: The strings are different!\n");
    } else {
      printf("Our result: The strings are identical!\n");
    }
  }
  res = strcmp(string1, string2);
  if (res == 0) {
    printf("strcmp result: The strings are identical!\n");
  } else {
    printf("strcmp result: The strings are different!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x34(%rbp),%eax
jle    11dc <main+0xac>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1289 <main+0x159>
mov    -0x30(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11fb <main+0xcb>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1284 <main+0x154>
jmp    1200 <main+0xd0>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1254 <main+0x124>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x20(%rbp),%rcx
movslq -0x28(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1246 <main+0x116>
cmpl   $0x0,-0x2c(%rbp)
jne    1246 <main+0x116>
movl   $0x1,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1200 <main+0xd0>
cmpl   $0x1,-0x2c(%rbp)
jne    1271 <main+0x141>
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    127f <main+0x14f>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1284 <main+0x154>
jmp    1289 <main+0x159>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcmp@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    12b6 <main+0x186>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c4 <main+0x194>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%r14
lea    0xead(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeaa(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0xf10(%rip),%rdi
cmp    %eax,%ebp
jg     11c7 <main+0x87>
jl     11c7 <main+0x87>
mov    (%rbx),%al
test   %al,%al
je     11c0 <main+0x80>
xor    %ecx,%ecx
mov    $0x1,%edx
xor    %esi,%esi
nopl   0x0(%rax)
mov    %esi,%ebp
test   %esi,%esi
cmove  %edx,%esi
cmp    (%r14,%rcx,1),%al
cmove  %ebp,%esi
movzbl 0x1(%rbx,%rcx,1),%eax
add    $0x1,%rcx
test   %al,%al
jne    11a0 <main+0x60>
cmp    $0x1,%esi
je     11c7 <main+0x87>
lea    0xe55(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
lea    0xe8d(%rip),%rax
lea    0xe5c(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"String 1: %s\0A\00"
@.str.1 = [14 x i8] c"String 2: %s\0A\00"
@.str.2 = [40 x i8] c"Our result: The strings are different!\0A\00"
@.str.3 = [40 x i8] c"Our result: The strings are identical!\0A\00"
@.str.4 = [43 x i8] c"strcmp result: The strings are identical!\0A\00"
@.str.5 = [43 x i8] c"strcmp result: The strings are different!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
store i8* %15, i8** %6
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
store i8* %18, i8** %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%19 = load i8*, i8** %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %21)
store i32 0, i32* %11
store i32 0, i32* %12
%23 = load i8*, i8** %6
%24 = call i32 @strlen(i8* %23)
store i32 %24, i32* %11
%25 = load i8*, i8** %7
%26 = call i32 @strlen(i8* %25)
store i32 %26, i32* %12
%27 = load i32, i32* %11
%28 = load i32, i32* %12
%29 = icmp sgt i32 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
br label %77
32: ; preds = %2
%33 = load i32, i32* %11
%34 = load i32, i32* %12
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
br label %76
38: ; preds = %32
br label %39
39: ; preds = %65, %38
%40 = load i8*, i8** %6
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %68
47: ; preds = %39
%48 = load i8*, i8** %6
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = load i8*, i8** %7
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp ne i32 %53, %59
br i1 %60, label %61, label %65
61: ; preds = %47
%62 = load i32, i32* %10
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %61
store i32 1, i32* %10
br label %65
65: ; preds = %64, %61, %47
%66 = load i32, i32* %9
%67 = add nsw i32 %66, 1
store i32 %67, i32* %9
br label %39
68: ; preds = %39
%69 = load i32, i32* %10
%70 = icmp eq i32 %69, 1
br i1 %70, label %71, label %73
71: ; preds = %68
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
br label %75
73: ; preds = %68
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
br label %75
75: ; preds = %73, %71
br label %76
76: ; preds = %75, %36
br label %77
77: ; preds = %76, %30
%78 = load i8*, i8** %6
%79 = load i8*, i8** %7
%80 = call i32 @strcmp(i8* %78, i8* %79)
store i32 %80, i32* %8
%81 = load i32, i32* %8
%82 = icmp eq i32 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %77
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
br label %87
85: ; preds = %77
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %87
87: ; preds = %85, %83
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"String 1: %s\0A\00"
@.str.1 = [14 x i8] c"String 2: %s\0A\00"
@str = [39 x i8] c"Our result: The strings are identical!\00"
@str.6 = [42 x i8] c"strcmp result: The strings are different!\00"
@str.7 = [42 x i8] c"strcmp result: The strings are identical!\00"
@str.10 = [39 x i8] c"Our result: The strings are different!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %4)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%9 = tail call i32 @strlen(i8* %4)
%10 = tail call i32 @strlen(i8* %6)
%11 = icmp sgt i32 %9, %10
br i1 %11, label %34, label %12
12: ; preds = %2
%13 = icmp slt i32 %9, %10
br i1 %13, label %34, label %14
14: ; preds = %12
%15 = load i8, i8* %4
%16 = icmp eq i8 %15, 0
br i1 %16, label %33, label %17
17: ; preds = %14, %17
%18 = phi i64 [ %27, %17 ], [ 0, %14 ]
%19 = phi i8 [ %29, %17 ], [ %15, %14 ]
%20 = phi i32 [ %26, %17 ], [ 0, %14 ]
%21 = getelementptr inbounds i8, i8* %6, i64 %18
%22 = load i8, i8* %21
%23 = icmp ne i8 %19, %22
%24 = icmp eq i32 %20, 0
%25 = select i1 %23, i1 %24, i1 false
%26 = select i1 %25, i32 1, i32 %20
%27 = add nuw nsw i64 %18, 1
%28 = getelementptr inbounds i8, i8* %4, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %31, label %17
31: ; preds = %17
%32 = icmp eq i32 %26, 1
br i1 %32, label %34, label %33
33: ; preds = %14, %31
br label %34
34: ; preds = %31, %12, %2, %33
%35 = phi i8* [ getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0), %33 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.10, i64 0, i64 0), %2 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.10, i64 0, i64 0), %12 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.10, i64 0, i64 0), %31 ]
%36 = tail call i32 @puts(i8* dereferenceable(1) %35)
%37 = tail call i32 @strcmp(i8* dereferenceable(1) %4, i8* dereferenceable(1) %6)
%38 = icmp eq i32 %37, 0
%39 = select i1 %38, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @str.7, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @str.6, i64 0, i64 0)
%40 = tail call i32 @puts(i8* dereferenceable(1) %39)
ret i32 0
}