#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*/ assert(int);
char *buildMsg(char *);
char strlen(char *);
scalar_t__ strncmp(char *, char *, char);
void testBuildMsg() {
  char *message = "test message please ignore";
  char *built_msg = buildMsg(message);
  assert(built_msg[0] == strlen(message));
  assert(strncmp(built_msg + 1, message, strlen(message)) == 0);
}


x86 assembly (clang, -O0):
<testBuildMsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <buildMsg@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %al,%cl
mov    -0x24(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsbl %al,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testBuildMsg>:
push   %rbp
push   %r14
push   %rbx
lea    0xeb5(%rip),%r14
mov    %r14,%rdi
call   1060 <buildMsg@plt>
mov    %rax,%rbx
mov    (%rax),%bpl
mov    %r14,%rdi
call   1040 <strlen@plt>
xor    %edi,%edi
cmp    %al,%bpl
sete   %dil
call   1050 <assert@plt>
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
movsbl %al,%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strncmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <assert@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"test message please ignore\00"
define void @testBuildMsg() {
%1 = alloca i8*
%2 = alloca i8*
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8** %1
%3 = load i8*, i8** %1
%4 = call i8* @buildMsg(i8* %3)
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = load i8*, i8** %1
%10 = call signext i8 @strlen(i8* %9)
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %8, %11
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8*, i8** %1
%18 = load i8*, i8** %1
%19 = call signext i8 @strlen(i8* %18)
%20 = call i64 @strncmp(i8* %16, i8* %17, i8 signext %19)
%21 = icmp eq i64 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"test message please ignore\00"
define void @testBuildMsg() {
%1 = tail call i8* @buildMsg(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%2 = load i8, i8* %1
%3 = tail call signext i8 @strlen(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8 %2, %3
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = getelementptr inbounds i8, i8* %1, i64 1
%8 = tail call signext i8 @strlen(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%9 = tail call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8 signext %8)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
ret void
}