#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 strcmp(const char *cs, const char *ct) {
  unsigned char c1, c2;
  while (1) {
    c1 = *cs++;
    c2 = *ct++;
    if (c1 != c2)
      return c1 < c2 ? -1 : 1;
    if (!c1)
      break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<strcmp>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x1a(%rbp)
movzbl -0x19(%rbp),%eax
movzbl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
je     1163 <strcmp+0x63>
movzbl -0x19(%rbp),%edx
movzbl -0x1a(%rbp),%esi
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    %esi,%edx
cmovl  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    117e <strcmp+0x7e>
cmpb   $0x0,-0x19(%rbp)
jne    1172 <strcmp+0x72>
jmp    1177 <strcmp+0x77>
jmp    110c <strcmp+0xc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp>:
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rdi,%rax,1),%ecx
cmp    (%rsi,%rax,1),%cl
jne    1124 <strcmp+0x24>
add    $0x1,%rax
test   %cl,%cl
jne    1110 <strcmp+0x10>
xor    %eax,%eax
ret
setae  %al
movzbl %al,%eax
add    %eax,%eax
add    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @strcmp(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
br label %8
8: ; preds = %2, %32
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %4
%11 = load i8, i8* %9
store i8 %11, i8* %6
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %5
%14 = load i8, i8* %12
store i8 %14, i8* %7
%15 = load i8, i8* %6
%16 = zext i8 %15 to i32
%17 = load i8, i8* %7
%18 = zext i8 %17 to i32
%19 = icmp ne i32 %16, %18
br i1 %19, label %20, label %28
20: ; preds = %8
%21 = load i8, i8* %6
%22 = zext i8 %21 to i32
%23 = load i8, i8* %7
%24 = zext i8 %23 to i32
%25 = icmp slt i32 %22, %24
%26 = zext i1 %25 to i64
%27 = select i1 %25, i32 -1, i32 1
store i32 %27, i32* %3
br label %34
28: ; preds = %8
%29 = load i8, i8* %6
%30 = icmp ne i8 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %28
br label %33
32: ; preds = %28
br label %8
33: ; preds = %31
store i32 0, i32* %3
br label %34
34: ; preds = %33, %20
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
define i32 @strcmp(i8* nocapture %0, i8* nocapture %1) {
br label %3
3: ; preds = %12, %2
%4 = phi i8* [ %1, %2 ], [ %13, %12 ]
%5 = phi i8* [ %0, %2 ], [ %14, %12 ]
%6 = load i8, i8* %5
%7 = load i8, i8* %4
%8 = icmp eq i8 %6, %7
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = icmp ult i8 %6, %7
%11 = select i1 %10, i32 -1, i32 1
br label %16
12: ; preds = %3
%13 = getelementptr inbounds i8, i8* %4, i64 1
%14 = getelementptr inbounds i8, i8* %5, i64 1
%15 = icmp eq i8 %6, 0
br i1 %15, label %16, label %3
16: ; preds = %12, %9
%17 = phi i32 [ %11, %9 ], [ 0, %12 ]
ret i32 %17
}