#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*/ printf(char *, ...);
int strcasecmp(char *, char *);
int strcmp(char *, char *);
int strncasecmp(char *, char *, int);
int strncmp(char *, char *, int);
void strcmp_test1() {
  int ret = 0;
  char *tmp = "2HOUR";
  printf("--------- [TEST1] ---------\n");
  printf("\n[strcmp]\n");
  ret = strcmp(tmp, "1HOUR");
  printf("not matched ret=%d\n", ret);
  ret = strcmp(tmp, "2HOUR");
  printf("    matched ret=%d\n", ret);
  ret = strcmp(tmp, "3HOUR");
  printf("not matched ret=%d\n", ret);
  printf("\n[strcasecmp]\n");
  ret = strcasecmp(tmp, "2hour");
  printf("matched ret=%d\n", ret);
  ret = strcasecmp(tmp, "2HouR");
  printf("matched ret=%d\n", ret);
  ret = strcasecmp(tmp, "2hOUr");
  printf("matched ret=%d\n", ret);
  tmp = "1";
  printf("\n[strncmp]\n");
  ret = strncmp(tmp, "1HOUR", 1);
  printf("    matched ret=%d\n", ret);
  ret = strncmp(tmp, "1HOUR", 2);
  printf("not matched ret=%d\n", ret);
  printf("\n[strncasecmp]\n");
  ret = strncasecmp(tmp, "1hour", 1);
  printf("    matched ret=%d\n", ret);
  ret = strncasecmp(tmp, "1hour", 2);
  printf("not matched ret=%d\n", ret);
  return;
}


x86 assembly (clang, -O0):
<strcmp_test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1060 <strcmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1060 <strcmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1060 <strcmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe10(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xd9e(%rip),%rsi
mov    $0x1,%edx
call   1040 <strncmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xd75(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xdb1(%rip),%rsi
mov    $0x1,%edx
call   1070 <strncasecmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xd88(%rip),%rsi
mov    $0x2,%edx
call   1070 <strncasecmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xd04(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp_test1>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeef(%rip),%rdi
call   1050 <puts@plt>
lea    0xeff(%rip),%rdi
call   1050 <puts@plt>
lea    0xe95(%rip),%r15
mov    %r15,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe93(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xec5(%rip),%rdi
call   1050 <puts@plt>
lea    0xe45(%rip),%r12
lea    0xe72(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcasecmp@plt>
lea    0xe53(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe56(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcasecmp@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe41(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcasecmp@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe68(%rip),%rdi
call   1050 <puts@plt>
lea    0xe20(%rip),%r12
lea    0xdd9(%rip),%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <strncmp@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe21(%rip),%rdi
call   1050 <puts@plt>
lea    0xdd0(%rip),%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1070 <strncasecmp@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1070 <strncasecmp@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <printf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"2HOUR\00"
@.str.1 = [29 x i8] c"--------- [TEST1] ---------\0A\00"
@.str.2 = [11 x i8] c"\0A[strcmp]\0A\00"
@.str.3 = [6 x i8] c"1HOUR\00"
@.str.4 = [20 x i8] c"not matched ret=%d\0A\00"
@.str.5 = [20 x i8] c" matched ret=%d\0A\00"
@.str.6 = [6 x i8] c"3HOUR\00"
@.str.7 = [15 x i8] c"\0A[strcasecmp]\0A\00"
@.str.8 = [6 x i8] c"2hour\00"
@.str.9 = [16 x i8] c"matched ret=%d\0A\00"
@.str.10 = [6 x i8] c"2HouR\00"
@.str.11 = [6 x i8] c"2hOUr\00"
@.str.12 = [2 x i8] c"1\00"
@.str.13 = [12 x i8] c"\0A[strncmp]\0A\00"
@.str.14 = [16 x i8] c"\0A[strncasecmp]\0A\00"
@.str.15 = [6 x i8] c"1hour\00"
define void @strcmp_test1() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%5 = load i8*, i8** %2
%6 = call i32 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %7)
%9 = load i8*, i8** %2
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %1
%11 = load i32, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %11)
%13 = load i8*, i8** %2
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 %14, i32* %1
%15 = load i32, i32* %1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%18 = load i8*, i8** %2
%19 = call i32 @strcasecmp(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
store i32 %19, i32* %1
%20 = load i32, i32* %1
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %20)
%22 = load i8*, i8** %2
%23 = call i32 @strcasecmp(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
store i32 %23, i32* %1
%24 = load i32, i32* %1
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %24)
%26 = load i8*, i8** %2
%27 = call i32 @strcasecmp(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
store i32 %27, i32* %1
%28 = load i32, i32* %1
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %28)
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i8** %2
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
%31 = load i8*, i8** %2
%32 = call i32 @strncmp(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 1)
store i32 %32, i32* %1
%33 = load i32, i32* %1
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %33)
%35 = load i8*, i8** %2
%36 = call i32 @strncmp(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 2)
store i32 %36, i32* %1
%37 = load i32, i32* %1
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0))
%40 = load i8*, i8** %2
%41 = call i32 @strncasecmp(i8* %40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i32 1)
store i32 %41, i32* %1
%42 = load i32, i32* %1
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %42)
%44 = load i8*, i8** %2
%45 = call i32 @strncasecmp(i8* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i32 2)
store i32 %45, i32* %1
%46 = load i32, i32* %1
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %46)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"2HOUR\00"
@.str.3 = [6 x i8] c"1HOUR\00"
@.str.4 = [20 x i8] c"not matched ret=%d\0A\00"
@.str.5 = [20 x i8] c" matched ret=%d\0A\00"
@.str.8 = [6 x i8] c"2hour\00"
@.str.9 = [16 x i8] c"matched ret=%d\0A\00"
@.str.10 = [6 x i8] c"2HouR\00"
@.str.11 = [6 x i8] c"2hOUr\00"
@.str.12 = [2 x i8] c"1\00"
@.str.15 = [6 x i8] c"1hour\00"
@str = [28 x i8] c"--------- [TEST1] ---------\00"
@str.16 = [10 x i8] c"\0A[strcmp]\00"
@str.17 = [14 x i8] c"\0A[strcasecmp]\00"
@str.18 = [11 x i8] c"\0A[strncmp]\00"
@str.19 = [15 x i8] c"\0A[strncasecmp]\00"
define void @strcmp_test1() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.16, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 1)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 0)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 -1)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.17, i64 0, i64 0))
%7 = tail call i32 @strcasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %7)
%9 = tail call i32 @strcasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %9)
%11 = tail call i32 @strcasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %11)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.18, i64 0, i64 0))
%14 = tail call i32 @strncmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 1)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %14)
%16 = tail call i32 @strncmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 2)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.19, i64 0, i64 0))
%19 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i32 1)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %19)
%21 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i32 2)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %21)
ret void
}