#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 strcmp(char *, char *);
int main() {
  char string1[100];
  char string2[100];
  int result;
  printf("请输入字符串(1) ==>");
  gets(string1);
  printf("请输入字符串(2) ==>");
  gets(string2);
  result = strcmp(string1, string2);
  switch (result) {
  case 0:
    printf("字符串(1)等于字符串(2)\n");
    break;
  case 1:
    printf("字符串(1)大于字符串(2)\n");
    break;
  case -1:
    printf("字符串(1)小于字符串(2)\n");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    %rdi,-0xf8(%rbp)
call   1050 <gets@plt>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
lea    -0xe0(%rbp),%rdi
mov    %rdi,-0xf0(%rbp)
call   1050 <gets@plt>
mov    -0xf8(%rbp),%rdi
mov    -0xf0(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %eax,-0xe4(%rbp)
mov    -0xe4(%rbp),%eax
mov    %eax,-0xe8(%rbp)
sub    $0xffffffff,%eax
je     11f9 <main+0xc9>
jmp    11b0 <main+0x80>
mov    -0xe8(%rbp),%eax
test   %eax,%eax
je     11d7 <main+0xa7>
jmp    11c3 <main+0x93>
mov    -0xe8(%rbp),%eax
sub    $0x1,%eax
je     11e8 <main+0xb8>
jmp    1205 <main+0xd5>
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
jmp    1205 <main+0xd5>
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
jmp    1205 <main+0xd5>
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
lea    0x70(%rsp),%r14
mov    %r14,%rdi
call   1060 <gets@plt>
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
add    $0x1,%eax
cmp    $0x2,%eax
ja     11a2 <main+0x62>
cltq
lea    0xefe(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E5\AD\97\E7\AC\A6\E4\B8\B2(1) ==>\00"
@.str.1 = [26 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E5\AD\97\E7\AC\A6\E4\B8\B2(2) ==>\00"
@.str.2 = [32 x i8] c"\E5\AD\97\E7\AC\A6\E4\B8\B2(1)\E7\AD\89\E4\BA\8E\E5\AD\97\E7\AC\A6\E4\B8\B2(2)\0A\00"
@.str.3 = [32 x i8] c"\E5\AD\97\E7\AC\A6\E4\B8\B2(1)\E5\A4\A7\E4\BA\8E\E5\AD\97\E7\AC\A6\E4\B8\B2(2)\0A\00"
@.str.4 = [32 x i8] c"\E5\AD\97\E7\AC\A6\E4\B8\B2(1)\E5\B0\8F\E4\BA\8E\E5\AD\97\E7\AC\A6\E4\B8\B2(2)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%13 = call i32 @strcmp(i8* %11, i8* %12)
store i32 %13, i32* %4
%14 = load i32, i32* %4
switch i32 %14, label %21 [
i32 0, label %15
i32 1, label %17
i32 -1, label %19
]
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %21
17: ; preds = %0
%18 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %21
19: ; preds = %0
%20 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
br label %21
21: ; preds = %0, %19, %17, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E5\AD\97\E7\AC\A6\E4\B8\B2(1) ==>\00"
@.str.1 = [26 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E5\AD\97\E7\AC\A6\E4\B8\B2(2) ==>\00"
@str = [31 x i8] c"\E5\AD\97\E7\AC\A6\E4\B8\B2(1)\E5\B0\8F\E4\BA\8E\E5\AD\97\E7\AC\A6\E4\B8\B2(2)\00"
@str.5 = [31 x i8] c"\E5\AD\97\E7\AC\A6\E4\B8\B2(1)\E5\A4\A7\E4\BA\8E\E5\AD\97\E7\AC\A6\E4\B8\B2(2)\00"
@str.6 = [31 x i8] c"\E5\AD\97\E7\AC\A6\E4\B8\B2(1)\E7\AD\89\E4\BA\8E\E5\AD\97\E7\AC\A6\E4\B8\B2(2)\00"
@reltable.main = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @str to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @str.6 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @str.5 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32)]
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 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
%9 = call i32 @strcmp(i8* %3, i8* %4)
%10 = add i32 %9, 1
%11 = icmp ult i32 %10, 3
br i1 %11, label %12, label %17
12: ; preds = %0
%13 = sext i32 %10 to i64
%14 = shl i64 %13, 2
%15 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.main to i8*), i64 %14)
%16 = call i32 @puts(i8* dereferenceable(1) %15)
br label %17
17: ; preds = %0, %12
ret i32 0
}