#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*/ memcpy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
void test_1(void) {
  char buf1[4] = "hell";
  printf("(%s)\n", buf1);
  char buf2[] = "hell";
  printf("(%s)\n", buf2);
  char buf3[8] = {0};
  memcpy(buf3, "hello", strlen("hell"));
  printf("(%s)\n", buf3);
  char buf4[4] = "hell";
  strcpy(buf4, "hell");
  printf("(%s)\n", buf4);
  char buf5[4] = "hell";
  buf5[4] = '3';
}


x86 assembly (clang, -O0):
<test_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xea2(%rip),%eax
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rsi
lea    0xe98(%rip),%rdi
call   1050 <printf@plt>
mov    0xe93(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xe8e(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0x9(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1050 <printf@plt>
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
lea    -0x11(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe58(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xe4b(%rip),%rsi
call   1070 <memcpy@plt>
lea    -0x11(%rbp),%rsi
lea    0xe30(%rip),%rdi
call   1050 <printf@plt>
mov    0xe21(%rip),%eax
mov    %eax,-0x15(%rbp)
lea    -0x15(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x15(%rbp),%rsi
lea    0xe07(%rip),%rdi
call   1050 <printf@plt>
mov    0xdf8(%rip),%eax
mov    %eax,-0x19(%rbp)
movb   $0x33,-0x15(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_1>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movl   $0x6c6c6568,0x14(%rsp)
6c
lea    0xea8(%rip),%r15
lea    0x14(%rsp),%rsi
mov    %r15,%rdi
call   1050 <printf@plt>
movb   $0x0,0xc(%rsp)
movl   $0x6c6c6568,0x8(%rsp)
6c
lea    0xe93(%rip),%r14
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
call   1050 <printf@plt>
movq   $0x0,0x18(%rsp)
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0xe68(%rip),%rsi
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
movl   $0x6c6c6568,0x10(%rsp)
6c
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.test_1.buf1 = [4 x i8] c"hell"
@.str = [6 x i8] c"(%s)\0A\00"
@__const.test_1.buf2 = [5 x i8] c"hell\00"
@.str.1 = [6 x i8] c"hello\00"
@.str.2 = [5 x i8] c"hell\00"
@__const.test_1.buf4 = [4 x i8] c"hell"
@__const.test_1.buf5 = [4 x i8] c"hell"
define void @test_1() {
%1 = alloca [4 x i8]
%2 = alloca [5 x i8]
%3 = alloca [8 x i8]
%4 = alloca [4 x i8]
%5 = alloca [4 x i8]
%6 = bitcast [4 x i8]* %1 to i8*
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%8 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = bitcast [5 x i8]* %2 to i8*
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%11 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = bitcast [8 x i8]* %3 to i8*
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%14 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @memcpy(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = bitcast [4 x i8]* %4 to i8*
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%20 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = bitcast [4 x i8]* %5 to i8*
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 4
store i8 51, i8* %24
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"(%s)\0A\00"
@.str.1 = [6 x i8] c"hello\00"
@.str.2 = [5 x i8] c"hell\00"
define void @test_1() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = alloca i64
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
store i32 1819043176, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%8 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%10 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @memcpy(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %9)
%13 = bitcast i32* %4 to i8*
store i32 1819043176, i32* %4
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %13)
ret void
}