#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *);
scalar_t__ strncmp(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ substring(char *, char *, int /*<<< orphan*/, int);
int main() {
  char *texto = malloc(6);
  if (strncmp(substring("Hello World", texto, 0, 5), "Hello", 5) == 0)
    printf("yep");
  free(texto);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x6,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe88(%rip),%rdi
xor    %edx,%edx
mov    $0x5,%ecx
call   1060 <substring@plt>
mov    %eax,%edi
lea    0xe7f(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    11ad <main+0x5d>
lea    0xe6a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x6,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe9b(%rip),%rdi
mov    %rax,%rsi
xor    %edx,%edx
mov    $0x5,%ecx
call   1060 <substring@plt>
lea    0xe91(%rip),%rsi
mov    %eax,%edi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1198 <main+0x48>
lea    0xe7f(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Hello World\00"
@.str.1 = [6 x i8] c"Hello\00"
@.str.2 = [4 x i8] c"yep\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i8* @malloc(i32 6)
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @substring(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %4, i32 0, i32 5)
%6 = call i64 @strncmp(i32 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
%11 = load i8*, i8** %2
%12 = call i32 @free(i8* %11)
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@.str = [12 x i8] c"Hello World\00"
@.str.1 = [6 x i8] c"Hello\00"
@.str.2 = [4 x i8] c"yep\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(6) i8* @malloc(i32 6)
%2 = tail call i32 @substring(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %1, i32 0, i32 5)
%3 = tail call i64 @strncmp(i32 %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = tail call i32 @free(i8* %1)
ret i32 0
}