#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*/ fgets(char *, int, int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  int index = 0;
  char string1[82] = {};
  char string2[82] = {};
  printf("Enter the first string: ");
  fgets(string1, 82, stdin);
  if ((string1[82 - 2] != 10) && (string1[82 - 2] != 0)) {
    printf("Warning! The string you entered is more than 80 characters long! "
           "Cutting off string!\n");
    string1[82 - 2] = 10;
    while (getchar() != '\n')
      ;
  }
  printf("Enter the second string: ");
  fgets(string2, 82, stdin);
  if ((string2[82 - 2] != 10) && (string2[82 - 2] != 0)) {
    printf("Warning! The string you entered is more than 80 characters long! "
           "Cutting off string!\n");
    string2[82 - 2] = 10;
    while (getchar() != 10)
      ;
  }
  while ((string1[index] == string2[index]) && (index < 82)) {
    index++;
    if (index >= 82)
      printf("Those strings are exactly the same.\n");
  }
  if (index < 82) {
    printf("Those two strings start to differ at character number %d.\n",
           (index + 1));
    printf("String 1: %s", string1);
    printf("String 2: %s%*c\n", string2, (index + 11), '^');
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x52,%edx
call   1040 <memset@plt>
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0x52,%edx
call   1040 <memset@plt>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e4c(%rip),%rax
mov    (%rax),%edx
mov    $0x52,%esi
call   1050 <fgets@plt>
movsbl -0x20(%rbp),%eax
cmp    $0xa,%eax
je     11ee <main+0xae>
movsbl -0x20(%rbp),%eax
cmp    $0x0,%eax
je     11ee <main+0xae>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0xa,-0x20(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
cmp    $0xa,%eax
je     11e9 <main+0xa9>
jmp    11d4 <main+0x94>
jmp    11ee <main+0xae>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xd0(%rbp),%rdi
mov    0x2dde(%rip),%rax
mov    (%rax),%edx
mov    $0x52,%esi
call   1050 <fgets@plt>
movsbl -0x80(%rbp),%eax
cmp    $0xa,%eax
je     125c <main+0x11c>
movsbl -0x80(%rbp),%eax
cmp    $0x0,%eax
je     125c <main+0x11c>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0xa,-0x80(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
cmp    $0xa,%eax
je     1257 <main+0x117>
jmp    1242 <main+0x102>
jmp    125c <main+0x11c>
jmp    1261 <main+0x121>
movslq -0x14(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%ecx
movslq -0x14(%rbp),%rax
movsbl -0xd0(%rbp,%rax,1),%edx
ff
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0xd1(%rbp)
jne    1293 <main+0x153>
cmpl   $0x52,-0x14(%rbp)
setl   %al
mov    %al,-0xd1(%rbp)
mov    -0xd1(%rbp),%al
test   $0x1,%al
jne    12a6 <main+0x166>
jmp    12cc <main+0x18c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x52,-0x14(%rbp)
jl     12c7 <main+0x187>
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1261 <main+0x121>
cmpl   $0x52,-0x14(%rbp)
jge    131c <main+0x1dc>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xd0(%rbp),%rsi
mov    -0x14(%rbp),%edx
add    $0xb,%edx
lea    0xde6(%rip),%rdi
mov    $0x5e,%ecx
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xb8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movw   $0x0,0xb0(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movw   $0x0,0x50(%rsp)
lea    0xe61(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e3b(%rip),%r14
mov    (%r14),%edx
lea    0x60(%rsp),%rdi
mov    $0x52,%esi
call   1050 <fgets@plt>
mov    0xb0(%rsp),%al
test   %al,%al
je     11fc <main+0xbc>
cmp    $0xa,%al
je     11fc <main+0xbc>
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
movb   $0xa,0xb0(%rsp)
0a
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%eax
jne    11f0 <main+0xb0>
lea    0xe16(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%edx
mov    %rsp,%rdi
mov    $0x52,%esi
call   1050 <fgets@plt>
mov    0x50(%rsp),%al
test   %al,%al
je     124c <main+0x10c>
cmp    $0xa,%al
je     124c <main+0x10c>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
movb   $0xa,0x50(%rsp)
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%eax
jne    1240 <main+0x100>
mov    0x60(%rsp),%al
cmp    (%rsp),%al
jne    1287 <main+0x147>
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
lea    0x1(%rax),%rbx
movzbl 0x61(%rsp,%rax,1),%ecx
cmp    0x1(%rsp,%rax,1),%cl
jne    1287 <main+0x147>
cmp    $0x50,%rbx
ja     12d3 <main+0x193>
movzbl 0x62(%rsp,%rax,1),%ecx
lea    0x2(%rax),%rbx
cmp    0x2(%rsp,%rax,1),%cl
mov    %rbx,%rax
je     1260 <main+0x120>
lea    0x1(%rbx),%esi
lea    0xda2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdcf(%rip),%rdi
lea    0x60(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xb,%ebx
lea    0xdc6(%rip),%rdi
mov    %rsp,%rsi
mov    %ebx,%edx
mov    $0x5e,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xdb2(%rip),%rdi
call   1030 <puts@plt>
jmp    12c6 <main+0x186>

LLVM IR (-O0):
@.str = [25 x i8] c"Enter the first string: \00"
@stdin = global i32 0
@.str.1 = [86 x i8] c"Warning! The string you entered is more than 80 characters long! Cutting off string!\0A\00"
@.str.2 = [26 x i8] c"Enter the second string: \00"
@.str.3 = [37 x i8] c"Those strings are exactly the same.\0A\00"
@.str.4 = [59 x i8] c"Those two strings start to differ at character number %d.\0A\00"
@.str.5 = [13 x i8] c"String 1: %s\00"
@.str.6 = [17 x i8] c"String 2: %s%*c\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [82 x i8]
%8 = alloca [82 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = bitcast [82 x i8]* %7 to i8*
%10 = bitcast [82 x i8]* %8 to i8*
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [82 x i8], [82 x i8]* %7, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %12, i32 82, i32 %13)
%15 = getelementptr inbounds [82 x i8], [82 x i8]* %7, i64 0, i64 80
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 10
br i1 %18, label %19, label %32
19: ; preds = %2
%20 = getelementptr inbounds [82 x i8], [82 x i8]* %7, i64 0, i64 80
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.1, i64 0, i64 0))
%26 = getelementptr inbounds [82 x i8], [82 x i8]* %7, i64 0, i64 80
store i8 10, i8* %26
br label %27
27: ; preds = %30, %24
%28 = call i32 (...) @getchar()
%29 = icmp ne i32 %28, 10
br i1 %29, label %30, label %31
30: ; preds = %27
br label %27
31: ; preds = %27
br label %32
32: ; preds = %31, %19, %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%34 = getelementptr inbounds [82 x i8], [82 x i8]* %8, i64 0, i64 0
%35 = load i32, i32* @stdin
%36 = call i32 @fgets(i8* %34, i32 82, i32 %35)
%37 = getelementptr inbounds [82 x i8], [82 x i8]* %8, i64 0, i64 80
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 10
br i1 %40, label %41, label %54
41: ; preds = %32
%42 = getelementptr inbounds [82 x i8], [82 x i8]* %8, i64 0, i64 80
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %54
46: ; preds = %41
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.1, i64 0, i64 0))
%48 = getelementptr inbounds [82 x i8], [82 x i8]* %8, i64 0, i64 80
store i8 10, i8* %48
br label %49
49: ; preds = %52, %46
%50 = call i32 (...) @getchar()
%51 = icmp ne i32 %50, 10
br i1 %51, label %52, label %53
52: ; preds = %49
br label %49
53: ; preds = %49
br label %54
54: ; preds = %53, %41, %32
br label %55
55: ; preds = %79, %54
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [82 x i8], [82 x i8]* %7, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [82 x i8], [82 x i8]* %8, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %60, %65
br i1 %66, label %67, label %70
67: ; preds = %55
%68 = load i32, i32* %6
%69 = icmp slt i32 %68, 82
br label %70
70: ; preds = %67, %55
%71 = phi i1 [ false, %55 ], [ %69, %67 ]
br i1 %71, label %72, label %80
72: ; preds = %70
%73 = load i32, i32* %6
%74 = add nsw i32 %73, 1
store i32 %74, i32* %6
%75 = load i32, i32* %6
%76 = icmp sge i32 %75, 82
br i1 %76, label %77, label %79
77: ; preds = %72
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
br label %79
79: ; preds = %77, %72
br label %55
80: ; preds = %70
%81 = load i32, i32* %6
%82 = icmp slt i32 %81, 82
br i1 %82, label %83, label %93
83: ; preds = %80
%84 = load i32, i32* %6
%85 = add nsw i32 %84, 1
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0), i32 %85)
%87 = getelementptr inbounds [82 x i8], [82 x i8]* %7, i64 0, i64 0
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %87)
%89 = getelementptr inbounds [82 x i8], [82 x i8]* %8, i64 0, i64 0
%90 = load i32, i32* %6
%91 = add nsw i32 %90, 11
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %89, i32 %91, i32 94)
br label %93
93: ; preds = %83, %80
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Enter the first string: \00"
@stdin = global i32 0
@.str.2 = [26 x i8] c"Enter the second string: \00"
@.str.4 = [59 x i8] c"Those two strings start to differ at character number %d.\0A\00"
@.str.5 = [13 x i8] c"String 1: %s\00"
@.str.6 = [17 x i8] c"String 2: %s%*c\0A\00"
@str = [36 x i8] c"Those strings are exactly the same.\00"
@str.8 = [85 x i8] c"Warning! The string you entered is more than 80 characters long! Cutting off string!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [82 x i8]
%4 = alloca [82 x i8]
%5 = getelementptr inbounds [82 x i8], [82 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [82 x i8], [82 x i8]* %4, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %5, i32 82, i32 %8)
%10 = getelementptr inbounds [82 x i8], [82 x i8]* %3, i64 0, i64 80
%11 = load i8, i8* %10
switch i8 %11, label %12 [
i8 10, label %17
i8 0, label %17
]
12: ; preds = %2
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([85 x i8], [85 x i8]* @str.8, i64 0, i64 0))
store i8 10, i8* %10
br label %14
14: ; preds = %14, %12
%15 = call i32 (...) @getchar()
%16 = icmp eq i32 %15, 10
br i1 %16, label %17, label %14
17: ; preds = %14, %2, %2
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* @stdin
%20 = call i32 @fgets(i8* %6, i32 82, i32 %19)
%21 = getelementptr inbounds [82 x i8], [82 x i8]* %4, i64 0, i64 80
%22 = load i8, i8* %21
switch i8 %22, label %23 [
i8 10, label %28
i8 0, label %28
]
23: ; preds = %17
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([85 x i8], [85 x i8]* @str.8, i64 0, i64 0))
store i8 10, i8* %21
br label %25
25: ; preds = %25, %23
%26 = call i32 (...) @getchar()
%27 = icmp eq i32 %26, 10
br i1 %27, label %28, label %25
28: ; preds = %25, %17, %17
%29 = load i8, i8* %5
%30 = load i8, i8* %6
%31 = icmp eq i8 %29, %30
br i1 %31, label %32, label %54
32: ; preds = %28, %45
%33 = phi i64 [ %43, %45 ], [ 0, %28 ]
%34 = or i64 %33, 1
%35 = getelementptr inbounds [82 x i8], [82 x i8]* %3, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = getelementptr inbounds [82 x i8], [82 x i8]* %4, i64 0, i64 %34
%38 = load i8, i8* %37
%39 = icmp eq i8 %36, %38
br i1 %39, label %42, label %51
40: ; preds = %42
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
br label %61
42: ; preds = %32
%43 = add nuw nsw i64 %33, 2
%44 = icmp ugt i64 %34, 80
br i1 %44, label %40, label %45
45: ; preds = %42
%46 = getelementptr inbounds [82 x i8], [82 x i8]* %3, i64 0, i64 %43
%47 = load i8, i8* %46
%48 = getelementptr inbounds [82 x i8], [82 x i8]* %4, i64 0, i64 %43
%49 = load i8, i8* %48
%50 = icmp eq i8 %47, %49
br i1 %50, label %32, label %51
51: ; preds = %45, %32
%52 = phi i64 [ %34, %32 ], [ %43, %45 ]
%53 = trunc i64 %52 to i32
br label %54
54: ; preds = %51, %28
%55 = phi i32 [ %53, %51 ], [ 0, %28 ]
%56 = add nuw nsw i32 %55, 1
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0), i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %5)
%59 = add nuw nsw i32 %55, 11
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %6, i32 %59, i32 94)
br label %61
61: ; preds = %40, %54
ret i32 0
}