#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 fast_strcmp(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, ...);
int main(void) {
  char s1[256], s2[256];
  printf("s1: ");
  if (scanf("%255[^\n]%*[^\n]", s1) != 1) {
    return 1;
  }
  scanf("%*c");
  printf("s2: ");
  if (scanf("%255[^\n]%*[^\n]", s2) != 1) {
    return 1;
  }
  scanf("%*c");
  printf("fast_strcmp(s1, s2) = %d\n", fast_strcmp(s1, s2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     117a <main+0x4a>
movl   $0x1,-0x4(%rbp)
jmp    11f8 <main+0xc8>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x210(%rbp),%rsi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     11c0 <main+0x90>
movl   $0x1,-0x4(%rbp)
jmp    11f8 <main+0xc8>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x110(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1040 <fast_strcmp@plt>
mov    %eax,%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x200,%rsp
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    0x100(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    $0x1,%ebx
cmp    $0x1,%eax
jne    11c8 <main+0x98>
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe7c(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11c8 <main+0x98>
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0x100(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <fast_strcmp@plt>
lea    0xe60(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x200,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"s1: \00"
@.str.1 = [15 x i8] c"%255[^\0A]%*[^\0A]\00"
@.str.2 = [4 x i8] c"%*c\00"
@.str.3 = [5 x i8] c"s2: \00"
@.str.4 = [26 x i8] c"fast_strcmp(s1, s2) = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = icmp ne i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 1, i32* %1
br label %22
9: ; preds = %0
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %9
store i32 1, i32* %1
br label %22
16: ; preds = %9
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%20 = call i32 @fast_strcmp(i8* %18, i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %20)
store i32 0, i32* %1
br label %22
22: ; preds = %16, %15, %8
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [5 x i8] c"s1: \00"
@.str.1 = [15 x i8] c"%255[^\0A]%*[^\0A]\00"
@.str.2 = [4 x i8] c"%*c\00"
@.str.3 = [5 x i8] c"s2: \00"
@.str.4 = [26 x i8] c"fast_strcmp(s1, s2) = %d\0A\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %17
8: ; preds = %0
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @fast_strcmp(i8* %3, i8* %4)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %8, %0, %13
%18 = phi i32 [ 0, %13 ], [ 1, %0 ], [ 1, %8 ]
ret i32 %18
}