#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 StrCompare(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int strcmp(char *, char *);
void TestStrCompare() {
  char str[] = "TestCompare";
  char case_str[] = "testcompare";
  int res1, res2;
  printf("===========================\n"
         "Test StrCompare\n"
         "===========================\n");
  printf("Test1:\n");
  res1 = StrCompare(str, "TestCompare");
  res2 = strcmp(str, "TestCompare");
  ((res1 * res2 < 0) || (res1 == 0 && res2 == 0)) ? printf("Correct!\n")
                                                  : printf("Wrong!\n");
  printf("Your     Answer: [%d]\n", res1);
  printf("String.h Answer: [%d]\n", res2);
  printf("\nTest2:\n");
  res1 = StrCompare(case_str, "TestCompare");
  res2 = strcmp(case_str, "TestCompare");
  ((res1 * res2 > 0) || (res1 == 0 && res2 == 0)) ? printf("Correct!\n")
                                                  : printf("Wrong!\n");
  printf("Your     Answer: [%d]\n", res1);
  printf("String.h Answer: [%d]\n", res2);
  printf("\nTest3:\n");
  res1 = StrCompare(str, "Test");
  res2 = strcmp(str, "Test");
  ((res1 * res2 > 0) || (res1 == 0 && res2 == 0)) ? printf("Correct!\n")
                                                  : printf("Wrong!\n");
  printf("Your     Answer: [%d]\n", res1);
  printf("String.h Answer: [%d]\n", res2);
  printf("\nTest4:\n");
  res1 = StrCompare(str, "TestCompareLong");
  res2 = strcmp(str, "TestCompareLong");
  ((res1 * res2 > 0) || (res1 == 0 && res2 == 0)) ? printf("Correct!\n")
                                                  : printf("Wrong!\n");
  printf("Your     Answer: [%d]\n", res1);
  printf("String.h Answer: [%d]\n", res2);
  printf("\nTest5:\n");
  res1 = StrCompare(str, "");
  res2 = strcmp(str, "");
  ((res1 * res2 > 0) || (res1 == 0 && res2 == 0)) ? printf("Correct!\n")
                                                  : printf("Wrong!\n");
  printf("Your     Answer: [%d]\n", res1);
  printf("String.h Answer: [%d]\n", res2);
  return;
}


x86 assembly (clang, -O0):
<TestStrCompare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xebf(%rip),%eax
mov    %eax,-0x4(%rbp)
mov    0xeb9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb7(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xc(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1030 <StrCompare@plt>
mov    %eax,-0x1c(%rbp)
lea    -0xc(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1050 <strcmp@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
cmp    $0x0,%eax
jl     11c6 <TestStrCompare+0x96>
cmpl   $0x0,-0x1c(%rbp)
jne    11d9 <TestStrCompare+0xa9>
cmpl   $0x0,-0x20(%rbp)
jne    11d9 <TestStrCompare+0xa9>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e7 <TestStrCompare+0xb7>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   1030 <StrCompare@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xdcb(%rip),%rsi
call   1050 <strcmp@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
cmp    $0x0,%eax
jg     1261 <TestStrCompare+0x131>
cmpl   $0x0,-0x1c(%rbp)
jne    1274 <TestStrCompare+0x144>
cmpl   $0x0,-0x20(%rbp)
jne    1274 <TestStrCompare+0x144>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1282 <TestStrCompare+0x152>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xc(%rbp),%rdi
lea    0xdfe(%rip),%rsi
call   1030 <StrCompare@plt>
mov    %eax,-0x1c(%rbp)
lea    -0xc(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   1050 <strcmp@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
cmp    $0x0,%eax
jg     12fc <TestStrCompare+0x1cc>
cmpl   $0x0,-0x1c(%rbp)
jne    130f <TestStrCompare+0x1df>
cmpl   $0x0,-0x20(%rbp)
jne    130f <TestStrCompare+0x1df>
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    131d <TestStrCompare+0x1ed>
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xd54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xc(%rbp),%rdi
lea    0xd71(%rip),%rsi
call   1030 <StrCompare@plt>
mov    %eax,-0x1c(%rbp)
lea    -0xc(%rbp),%rdi
lea    0xd5e(%rip),%rsi
call   1050 <strcmp@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
cmp    $0x0,%eax
jg     1397 <TestStrCompare+0x267>
cmpl   $0x0,-0x1c(%rbp)
jne    13aa <TestStrCompare+0x27a>
cmpl   $0x0,-0x20(%rbp)
jne    13aa <TestStrCompare+0x27a>
lea    0xccb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13b8 <TestStrCompare+0x288>
lea    0xcc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xcb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xcbf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xc(%rbp),%rdi
lea    0xc87(%rip),%rsi
call   1030 <StrCompare@plt>
mov    %eax,-0x1c(%rbp)
lea    -0xc(%rbp),%rdi
lea    0xc74(%rip),%rsi
call   1050 <strcmp@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
cmp    $0x0,%eax
jg     1432 <TestStrCompare+0x302>
cmpl   $0x0,-0x1c(%rbp)
jne    1445 <TestStrCompare+0x315>
cmpl   $0x0,-0x20(%rbp)
jne    1445 <TestStrCompare+0x315>
lea    0xc30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1453 <TestStrCompare+0x323>
lea    0xc27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xc1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xc24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TestStrCompare>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movabs $0x706d6f4374736554,%rax
6f 6d 70
mov    %rax,0x8(%rsp)
movl   $0x657261,0x10(%rsp)
lea    0xea0(%rip),%r13
movabs $0x706d6f6374736574,%rax
6f 6d 70
mov    %rax,0x18(%rsp)
movl   $0x657261,0x20(%rsp)
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0d(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <StrCompare@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <strcmp@plt>
mov    %eax,%ebx
imul   %ebp,%eax
lea    0xf0d(%rip),%r14
lea    0xeff(%rip),%rdi
mov    %ebp,%ecx
or     %ebx,%ecx
cmove  %r14,%rdi
test   %eax,%eax
cmovs  %r14,%rdi
call   1030 <puts@plt>
lea    0xe33(%rip),%r15
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe37(%rip),%r12
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <StrCompare@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <strcmp@plt>
mov    %eax,%ebx
imul   %ebp,%eax
mov    %ebp,%ecx
or     %ebx,%ecx
lea    0xe8d(%rip),%r13
mov    %r13,%rdi
cmove  %r14,%rdi
test   %eax,%eax
cmovg  %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe44(%rip),%rdi
call   1030 <puts@plt>
lea    0xdcc(%rip),%rbx
lea    0x8(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <StrCompare@plt>
mov    %eax,%ebp
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
mov    %eax,%ebx
imul   %ebp,%eax
mov    %ebp,%ecx
or     %ebx,%ecx
mov    %r13,%rdi
cmove  %r14,%rdi
test   %eax,%eax
cmovg  %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r15,%r13
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd67(%rip),%r15
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xddf(%rip),%rdi
call   1030 <puts@plt>
lea    0xd64(%rip),%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <StrCompare@plt>
mov    %eax,%ebp
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
mov    %eax,%ebx
imul   %ebp,%eax
mov    %ebp,%ecx
or     %ebx,%ecx
lea    0xdbb(%rip),%rdi
cmove  %r14,%rdi
test   %eax,%eax
cmovg  %r14,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd85(%rip),%rdi
call   1030 <puts@plt>
lea    0xce5(%rip),%rsi
mov    %r12,%rdi
call   1040 <StrCompare@plt>
mov    %eax,%ebx
movzbl 0x8(%rsp),%ebp
imul   %ebp,%eax
test   %ebp,%ebp
lea    0xd66(%rip),%rcx
mov    %rcx,%rdi
cmove  %r14,%rdi
test   %ebx,%ebx
cmovne %rcx,%rdi
test   %eax,%eax
cmovg  %r14,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.TestStrCompare.str = [12 x i8] c"TestCompare\00"
@__const.TestStrCompare.case_str = [12 x i8] c"testcompare\00"
@.str = [73 x i8] c"===========================\0ATest StrCompare\0A===========================\0A\00"
@.str.1 = [8 x i8] c"Test1:\0A\00"
@.str.2 = [12 x i8] c"TestCompare\00"
@.str.3 = [10 x i8] c"Correct!\0A\00"
@.str.4 = [8 x i8] c"Wrong!\0A\00"
@.str.5 = [23 x i8] c"Your Answer: [%d]\0A\00"
@.str.6 = [23 x i8] c"String.h Answer: [%d]\0A\00"
@.str.7 = [9 x i8] c"\0ATest2:\0A\00"
@.str.8 = [9 x i8] c"\0ATest3:\0A\00"
@.str.9 = [5 x i8] c"Test\00"
@.str.10 = [9 x i8] c"\0ATest4:\0A\00"
@.str.11 = [16 x i8] c"TestCompareLong\00"
@.str.12 = [9 x i8] c"\0ATest5:\0A\00"
@.str.13 = [1 x i8] zeroinitializer
define void @TestStrCompare() {
%1 = alloca [12 x i8]
%2 = alloca [12 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [12 x i8]* %1 to i8*
%6 = bitcast [12 x i8]* %2 to i8*
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%10 = call i32 @StrCompare(i8* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 %10, i32* %3
%11 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 %12, i32* %4
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = mul nsw i32 %13, %14
%16 = icmp slt i32 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %0
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20, %0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %27
25: ; preds = %20, %17
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
%28 = phi i32 [ %24, %23 ], [ %26, %25 ]
%29 = load i32, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %4
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%34 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%35 = call i32 @StrCompare(i8* %34, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 %35, i32* %3
%36 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%37 = call i32 @strcmp(i8* %36, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 %37, i32* %4
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = mul nsw i32 %38, %39
%41 = icmp sgt i32 %40, 0
br i1 %41, label %48, label %42
42: ; preds = %27
%43 = load i32, i32* %3
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load i32, i32* %4
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %45, %27
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %52
50: ; preds = %45, %42
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %52
52: ; preds = %50, %48
%53 = phi i32 [ %49, %48 ], [ %51, %50 ]
%54 = load i32, i32* %3
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %4
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%59 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%60 = call i32 @StrCompare(i8* %59, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
store i32 %60, i32* %3
%61 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%62 = call i32 @strcmp(i8* %61, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
store i32 %62, i32* %4
%63 = load i32, i32* %3
%64 = load i32, i32* %4
%65 = mul nsw i32 %63, %64
%66 = icmp sgt i32 %65, 0
br i1 %66, label %73, label %67
67: ; preds = %52
%68 = load i32, i32* %3
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %75
70: ; preds = %67
%71 = load i32, i32* %4
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %70, %52
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %77
75: ; preds = %70, %67
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %77
77: ; preds = %75, %73
%78 = phi i32 [ %74, %73 ], [ %76, %75 ]
%79 = load i32, i32* %3
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %79)
%81 = load i32, i32* %4
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %81)
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
%84 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%85 = call i32 @StrCompare(i8* %84, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
store i32 %85, i32* %3
%86 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%87 = call i32 @strcmp(i8* %86, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
store i32 %87, i32* %4
%88 = load i32, i32* %3
%89 = load i32, i32* %4
%90 = mul nsw i32 %88, %89
%91 = icmp sgt i32 %90, 0
br i1 %91, label %98, label %92
92: ; preds = %77
%93 = load i32, i32* %3
%94 = icmp eq i32 %93, 0
br i1 %94, label %95, label %100
95: ; preds = %92
%96 = load i32, i32* %4
%97 = icmp eq i32 %96, 0
br i1 %97, label %98, label %100
98: ; preds = %95, %77
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %102
100: ; preds = %95, %92
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %102
102: ; preds = %100, %98
%103 = phi i32 [ %99, %98 ], [ %101, %100 ]
%104 = load i32, i32* %3
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %104)
%106 = load i32, i32* %4
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %106)
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
%109 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%110 = call i32 @StrCompare(i8* %109, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i64 0, i64 0))
store i32 %110, i32* %3
%111 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%112 = call i32 @strcmp(i8* %111, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i64 0, i64 0))
store i32 %112, i32* %4
%113 = load i32, i32* %3
%114 = load i32, i32* %4
%115 = mul nsw i32 %113, %114
%116 = icmp sgt i32 %115, 0
br i1 %116, label %123, label %117
117: ; preds = %102
%118 = load i32, i32* %3
%119 = icmp eq i32 %118, 0
br i1 %119, label %120, label %125
120: ; preds = %117
%121 = load i32, i32* %4
%122 = icmp eq i32 %121, 0
br i1 %122, label %123, label %125
123: ; preds = %120, %102
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %127
125: ; preds = %120, %117
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %127
127: ; preds = %125, %123
%128 = phi i32 [ %124, %123 ], [ %126, %125 ]
%129 = load i32, i32* %3
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %129)
%131 = load i32, i32* %4
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %131)
ret void
}

LLVM IR (-O2):
@__const.TestStrCompare.case_str = [12 x i8] c"testcompare\00"
@.str.2 = [12 x i8] c"TestCompare\00"
@.str.5 = [23 x i8] c"Your Answer: [%d]\0A\00"
@.str.6 = [23 x i8] c"String.h Answer: [%d]\0A\00"
@.str.9 = [5 x i8] c"Test\00"
@.str.11 = [16 x i8] c"TestCompareLong\00"
@.str.13 = [1 x i8] zeroinitializer
@str = [72 x i8] c"===========================\0ATest StrCompare\0A===========================\00"
@str.14 = [7 x i8] c"Test1:\00"
@str.16 = [8 x i8] c"\0ATest2:\00"
@str.18 = [8 x i8] c"\0ATest3:\00"
@str.20 = [8 x i8] c"\0ATest4:\00"
@str.22 = [8 x i8] c"\0ATest5:\00"
@str.23 = [7 x i8] c"Wrong!\00"
@str.28 = [9 x i8] c"Correct!\00"
define void @TestStrCompare() {
%1 = alloca [12 x i8]
%2 = alloca [12 x i8]
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.14, i64 0, i64 0))
%7 = call i32 @StrCompare(i8* %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @strcmp(i8* %3, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%9 = mul nsw i32 %8, %7
%10 = icmp slt i32 %9, 0
%11 = icmp eq i32 %7, 0
%12 = icmp eq i32 %8, 0
%13 = select i1 %11, i1 %12, i1 false
%14 = or i1 %10, %13
%15 = select i1 %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.28, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.23, i64 0, i64 0)
%16 = call i32 @puts(i8* dereferenceable(1) %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %7)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %8)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.16, i64 0, i64 0))
%20 = call i32 @StrCompare(i8* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @strcmp(i8* %4, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%22 = mul nsw i32 %21, %20
%23 = icmp sgt i32 %22, 0
%24 = icmp eq i32 %20, 0
%25 = icmp eq i32 %21, 0
%26 = select i1 %24, i1 %25, i1 false
%27 = or i1 %23, %26
%28 = select i1 %27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.28, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.23, i64 0, i64 0)
%29 = call i32 @puts(i8* dereferenceable(1) %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %20)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %21)
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.18, i64 0, i64 0))
%33 = call i32 @StrCompare(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%34 = call i32 @strcmp(i8* %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%35 = mul nsw i32 %34, %33
%36 = icmp sgt i32 %35, 0
%37 = icmp eq i32 %33, 0
%38 = icmp eq i32 %34, 0
%39 = select i1 %37, i1 %38, i1 false
%40 = or i1 %36, %39
%41 = select i1 %40, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.28, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.23, i64 0, i64 0)
%42 = call i32 @puts(i8* dereferenceable(1) %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %33)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %34)
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.20, i64 0, i64 0))
%46 = call i32 @StrCompare(i8* %3, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
%47 = call i32 @strcmp(i8* %3, i8* dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
%48 = mul nsw i32 %47, %46
%49 = icmp sgt i32 %48, 0
%50 = icmp eq i32 %46, 0
%51 = icmp eq i32 %47, 0
%52 = select i1 %50, i1 %51, i1 false
%53 = or i1 %49, %52
%54 = select i1 %53, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.28, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.23, i64 0, i64 0)
%55 = call i32 @puts(i8* dereferenceable(1) %54)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %46)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %47)
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.22, i64 0, i64 0))
%59 = call i32 @StrCompare(i8* %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i64 0, i64 0))
%60 = load i8, i8* %3
%61 = zext i8 %60 to i32
%62 = mul nsw i32 %59, %61
%63 = icmp sgt i32 %62, 0
%64 = icmp eq i32 %59, 0
%65 = icmp eq i8 %60, 0
%66 = select i1 %64, i1 %65, i1 false
%67 = select i1 %63, i1 true, i1 %66
%68 = select i1 %67, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.28, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.23, i64 0, i64 0)
%69 = call i32 @puts(i8* dereferenceable(1) %68)
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %59)
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %61)
ret void
}