#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 */
scalar_t__ _strncmp(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *, char *, char *);
int main() {
  char s1[] = "Hello";
  char s2[] = "Hello";
  printf("String 1: %s\nString 2: %s\n%s\n", s1, s2,
         _strncmp(s1, s2, 3) == 0  ? "Strings are equal"
         : _strncmp(s1, s2, 3) > 0 ? "String 1 is bigger than string 2"
                                   : "String 1 is less than string 2");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xec5(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xeb7(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xeb1(%rip),%ax
mov    %ax,-0xc(%rbp)
lea    -0xa(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0xa(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x3,%edx
call   1030 <_strncmp@plt>
cmp    $0x0,%rax
jne    1193 <main+0x73>
lea    0xe9a(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11c2 <main+0xa2>
lea    -0xa(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x3,%edx
call   1030 <_strncmp@plt>
mov    %rax,%rdx
lea    0xea8(%rip),%rax
lea    0xe80(%rip),%rcx
cmp    $0x0,%rdx
cmovg  %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rcx
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movw   $0x6f,0x14(%rsp)
movl   $0x6c6c6548,0x10(%rsp)
6c
movw   $0x6f,0xc(%rsp)
movl   $0x6c6c6548,0x8(%rsp)
6c
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x3,%edx
call   1030 <_strncmp@plt>
test   %rax,%rax
je     1186 <main+0x66>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x3,%edx
call   1030 <_strncmp@plt>
test   %rax,%rax
lea    0xebd(%rip),%rax
lea    0xed7(%rip),%rcx
cmovg  %rax,%rcx
jmp    118d <main+0x6d>
lea    0xe97(%rip),%rcx
lea    0xe72(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.s1 = [6 x i8] c"Hello\00"
@__const.main.s2 = [6 x i8] c"Hello\00"
@.str = [30 x i8] c"String 1: %s\0AString 2: %s\0A%s\0A\00"
@.str.1 = [18 x i8] c"Strings are equal\00"
@.str.2 = [33 x i8] c"String 1 is bigger than string 2\00"
@.str.3 = [31 x i8] c"String 1 is less than string 2\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = alloca [6 x i8]
store i32 0, i32* %1
%4 = bitcast [6 x i8]* %2 to i8*
%5 = bitcast [6 x i8]* %3 to i8*
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%10 = call i64 @_strncmp(i8* %8, i8* %9, i32 3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %0
br label %20
13: ; preds = %0
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%15 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%16 = call i64 @_strncmp(i8* %14, i8* %15, i32 3)
%17 = icmp sgt i64 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0)
br label %20
20: ; preds = %13, %12
%21 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %12 ], [ %19, %13 ]
%22 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %7, i8* %21)
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@__const.main.s2 = [6 x i8] c"Hello\00"
@.str = [30 x i8] c"String 1: %s\0AString 2: %s\0A%s\0A\00"
@.str.1 = [18 x i8] c"Strings are equal\00"
@.str.2 = [33 x i8] c"String 1 is bigger than string 2\00"
@.str.3 = [31 x i8] c"String 1 is less than string 2\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [6 x i8]
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%5 = call i64 @_strncmp(i8* %3, i8* %4, i32 3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = call i64 @_strncmp(i8* %3, i8* %4, i32 3)
%9 = icmp sgt i64 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0)
br label %11
11: ; preds = %0, %7
%12 = phi i8* [ %10, %7 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %0 ]
%13 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4, i8* %12)
ret i32 0
}