#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 Strncmp(char const *, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ strlen(char const *);
int strncmp(char const *, char const *, int /*<<< orphan*/);
int main(void) {
  int ret = 0;
  const char *s = "hello";
  ret = Strncmp(s, s, strlen(s));
  printf("%d\n", ret);
  ret = strncmp(s, s, strlen(s));
  printf("%d\n", ret);
  putchar('\n');
  const char *t = "hello!";
  ret = Strncmp(s, t, strlen(t));
  printf("%d\n", ret);
  ret = strncmp(s, t, strlen(t));
  printf("%d\n", ret);
  putchar('\n');
  ret = Strncmp(s, t, strlen(s));
  printf("%d\n", ret);
  ret = strncmp(s, t, strlen(s));
  printf("%d\n", ret);
  putchar('\n');
  ret = Strncmp(t, s, strlen(t));
  printf("%d\n", ret);
  ret = strncmp(t, s, strlen(t));
  printf("%d\n", ret);
  putchar('\n');
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe80(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    %eax,%edx
call   1080 <Strncmp@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe41(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe01(%rip),%rdi
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdef(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
call   1080 <Strncmp@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xdb2(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xd78(%rip),%rdi
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
call   1080 <Strncmp@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xd34(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xcfa(%rip),%rdi
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1080 <Strncmp@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xcb6(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xc7c(%rip),%rdi
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xe94(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1080 <Strncmp@plt>
lea    0xe7e(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe48(%rip),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1080 <Strncmp@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1080 <Strncmp@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1080 <Strncmp@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [7 x i8] c"hello!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %3
%6 = load i8*, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = call i32 @Strncmp(i8* %5, i8* %6, i32 %8)
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i8*, i8** %3
%13 = load i8*, i8** %3
%14 = load i8*, i8** %3
%15 = call i32 @strlen(i8* %14)
%16 = call i32 @strncmp(i8* %12, i8* %13, i32 %15)
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = call i32 @putchar(i8 signext 10)
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %4
%20 = load i8*, i8** %3
%21 = load i8*, i8** %4
%22 = load i8*, i8** %4
%23 = call i32 @strlen(i8* %22)
%24 = call i32 @Strncmp(i8* %20, i8* %21, i32 %23)
store i32 %24, i32* %2
%25 = load i32, i32* %2
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load i8*, i8** %3
%28 = load i8*, i8** %4
%29 = load i8*, i8** %4
%30 = call i32 @strlen(i8* %29)
%31 = call i32 @strncmp(i8* %27, i8* %28, i32 %30)
store i32 %31, i32* %2
%32 = load i32, i32* %2
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = call i32 @putchar(i8 signext 10)
%35 = load i8*, i8** %3
%36 = load i8*, i8** %4
%37 = load i8*, i8** %3
%38 = call i32 @strlen(i8* %37)
%39 = call i32 @Strncmp(i8* %35, i8* %36, i32 %38)
store i32 %39, i32* %2
%40 = load i32, i32* %2
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = load i8*, i8** %3
%43 = load i8*, i8** %4
%44 = load i8*, i8** %3
%45 = call i32 @strlen(i8* %44)
%46 = call i32 @strncmp(i8* %42, i8* %43, i32 %45)
store i32 %46, i32* %2
%47 = load i32, i32* %2
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %47)
%49 = call i32 @putchar(i8 signext 10)
%50 = load i8*, i8** %4
%51 = load i8*, i8** %3
%52 = load i8*, i8** %4
%53 = call i32 @strlen(i8* %52)
%54 = call i32 @Strncmp(i8* %50, i8* %51, i32 %53)
store i32 %54, i32* %2
%55 = load i32, i32* %2
%56 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %55)
%57 = load i8*, i8** %4
%58 = load i8*, i8** %3
%59 = load i8*, i8** %4
%60 = call i32 @strlen(i8* %59)
%61 = call i32 @strncmp(i8* %57, i8* %58, i32 %60)
store i32 %61, i32* %2
%62 = load i32, i32* %2
%63 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %62)
%64 = call i32 @putchar(i8 signext 10)
%65 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [7 x i8] c"hello!\00"
define i32 @main() {
%1 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @Strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 @putchar(i8 signext 10)
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @Strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = tail call i32 @putchar(i8 signext 10)
%15 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @Strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = tail call i32 @putchar(i8 signext 10)
%22 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%23 = tail call i32 @Strncmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%26 = tail call i32 @strncmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = tail call i32 @putchar(i8 signext 10)
%29 = tail call i32 (...) @getchar()
ret i32 0
}