#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i, resu;
  char s1[100], s2[100];
  printf("input string1:\n");
  gets(s1);
  printf("input string2:\n");
  gets(s2);
  i = 0;
  while (s1[i] == s2[i] && s1[i] != '\0')
    i++;
  if (s1[i] == '\0' && s2[i] == '\0')
    resu = 0;
  else
    resu = s1[i] - s2[i];
  printf("\nresult :%d\n", resu);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <gets@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xe0(%rbp),%rdi
call   1040 <gets@plt>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%ecx
movslq -0x8(%rbp),%rax
movsbl -0xe0(%rbp,%rax,1),%edx
ff
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0xe1(%rbp)
jne    11a4 <main+0x84>
movslq -0x8(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0xe1(%rbp)
mov    -0xe1(%rbp),%al
test   $0x1,%al
jne    11b7 <main+0x97>
jmp    11c5 <main+0xa5>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116a <main+0x4a>
movslq -0x8(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
jne    11f8 <main+0xd8>
movslq -0x8(%rbp),%rax
movsbl -0xe0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jne    11f8 <main+0xd8>
movl   $0x0,-0xc(%rbp)
jmp    1212 <main+0xf2>
movslq -0x8(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
movslq -0x8(%rbp),%rcx
movsbl -0xe0(%rbp,%rcx,1),%ecx
ff
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0xd8,%rsp
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0x70(%rsp),%rdi
call   1050 <gets@plt>
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1050 <gets@plt>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl 0x70(%rsp,%rdx,1),%eax
movzbl (%rsp,%rdx,1),%ecx
test   %eax,%eax
je     1185 <main+0x55>
add    $0x1,%rdx
cmp    %cl,%al
je     1170 <main+0x40>
movsbl %cl,%edx
mov    %eax,%esi
sub    %edx,%esi
xor    %edx,%edx
or     %cl,%al
cmove  %edx,%esi
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"input string1:\0A\00"
@.str.1 = [16 x i8] c"input string2:\0A\00"
@.str.2 = [13 x i8] c"\0Aresult :%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = call i32 @gets(i8* %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
store i32 0, i32* %2
br label %12
12: ; preds = %33, %0
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %17, %22
br i1 %23, label %24, label %31
24: ; preds = %12
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br label %31
31: ; preds = %24, %12
%32 = phi i1 [ false, %12 ], [ %30, %24 ]
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
store i32 %35, i32* %2
br label %12
36: ; preds = %31
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %51
43: ; preds = %36
%44 = load i32, i32* %2
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %43
store i32 0, i32* %3
br label %63
51: ; preds = %43, %36
%52 = load i32, i32* %2
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = load i32, i32* %2
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = sub nsw i32 %56, %61
store i32 %62, i32* %3
br label %63
63: ; preds = %51, %50
%64 = load i32, i32* %3
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %64)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [13 x i8] c"\0Aresult :%d\0A\00"
@str = [15 x i8] c"input string1:\00"
@str.3 = [15 x i8] c"input string2:\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
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.3, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
br label %9
9: ; preds = %9, %0
%10 = phi i64 [ %18, %9 ], [ 0, %0 ]
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %10
%14 = load i8, i8* %13
%15 = icmp ne i8 %12, %14
%16 = icmp eq i8 %12, 0
%17 = or i1 %16, %15
%18 = add nuw i64 %10, 1
br i1 %17, label %19, label %9
19: ; preds = %9
%20 = icmp eq i8 %14, 0
%21 = select i1 %16, i1 %20, i1 false
%22 = sext i8 %12 to i32
%23 = sext i8 %14 to i32
%24 = sub nsw i32 %22, %23
%25 = select i1 %21, i32 0, i32 %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %25)
ret i32 0
}