#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*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  char *prog = argv[0];
  (void)argc;
  char str[24];
  char str2[24];
  int i;
  int n;
  sprintf(str, "Hello World!");
  printf("%s\n", str);
  i = 4;
  sprintf(str, "Value of i = %d", i);
  printf("%s\n", str);
  n = strlen(str);
  printf("lenght of str is %d\n", n);
  strcpy(str2, str);
  printf("str2 is: %s\n", str2);
  memset(str, 0, 24);
  memset(str, 'a', 10);
  printf("<%s>\n", str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x30(%rbp),%rsi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x4,-0x54(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x54(%rbp),%edx
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x50(%rbp),%rsi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
lea    -0x30(%rbp),%rdi
mov    $0x61,%esi
mov    $0xa,%edx
call   1060 <memset@plt>
lea    -0x30(%rbp),%rsi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movabs $0x6f57206f6c6c6548,%rax
20 57 6f
mov    %rax,(%rsp)
movabs $0x21646c726f5720,%rax
mov    %rax,0x5(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xe61(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe56(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    %rbx,%rdi
mov    $0x61,%esi
mov    $0xa,%edx
call   1070 <memset@plt>
lea    0xe31(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Hello World!\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [16 x i8] c"Value of i = %d\00"
@.str.3 = [21 x i8] c"lenght of str is %d\0A\00"
@.str.4 = [13 x i8] c"str2 is: %s\0A\00"
@.str.5 = [6 x i8] c"<%s>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [24 x i8]
%8 = alloca [24 x i8]
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
store i8* %13, i8** %6
%14 = load i32, i32* %4
%15 = getelementptr inbounds [24 x i8], [24 x i8]* %7, i64 0, i64 0
%16 = call i32 (i8*, i8*, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%17 = getelementptr inbounds [24 x i8], [24 x i8]* %7, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 4, i32* %9
%19 = getelementptr inbounds [24 x i8], [24 x i8]* %7, i64 0, i64 0
%20 = load i32, i32* %9
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [24 x i8], [24 x i8]* %7, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [24 x i8], [24 x i8]* %7, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
store i32 %25, i32* %10
%26 = load i32, i32* %10
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [24 x i8], [24 x i8]* %8, i64 0, i64 0
%29 = getelementptr inbounds [24 x i8], [24 x i8]* %7, i64 0, i64 0
%30 = call i32 @strcpy(i8* %28, i8* %29)
%31 = getelementptr inbounds [24 x i8], [24 x i8]* %8, i64 0, i64 0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds [24 x i8], [24 x i8]* %7, i64 0, i64 0
%34 = call i32 @memset(i8* %33, i8 signext 0, i32 24)
%35 = getelementptr inbounds [24 x i8], [24 x i8]* %7, i64 0, i64 0
%36 = call i32 @memset(i8* %35, i8 signext 97, i32 10)
%37 = getelementptr inbounds [24 x i8], [24 x i8]* %7, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Hello World!\00"
@.str.2 = [16 x i8] c"Value of i = %d\00"
@.str.3 = [21 x i8] c"lenght of str is %d\0A\00"
@.str.4 = [13 x i8] c"str2 is: %s\0A\00"
@.str.5 = [6 x i8] c"<%s>\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [24 x i8]
%4 = alloca [24 x i8]
%5 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [24 x i8], [24 x i8]* %4, i64 0, i64 0
%7 = call i32 @puts(i8* %5)
%8 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 4)
%9 = call i32 @puts(i8* %5)
%10 = call i32 @strlen(i8* %5)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = call i32 @strcpy(i8* %6, i8* %5)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%14 = call i32 @memset(i8* %5, i8 signext 0, i32 24)
%15 = call i32 @memset(i8* %5, i8 signext 97, i32 10)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %5)
ret i32 0
}