#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 */
typedef int /*<<< orphan*/ s4;
typedef int /*<<< orphan*/ s3;
typedef int /*<<< orphan*/ s2;
typedef int /*<<< orphan*/ s1;

/* Variables and functions */
int /*<<< orphan*/ helper(char *, char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strlen(char *);
int main(int argc, char *argv[]) {
  char *s1 = malloc(128);
  char s2[64];
  char *s3 = "this is a string";
  char *s4 = s2;
  printf("sizeof(s1) = %d\n", (int)sizeof(s1));
  printf("strlen(s1) = %d\n", (int)strlen(s1));
  helper("s1", s1);
  printf("sizeof(s2) = %d\n", (int)sizeof(s2));
  printf("strlen(s2) = %d\n", (int)strlen(s2));
  printf("s2: \"%s\"\n", s2);
  helper("s2", s2);
  printf("sizeof(s3) = %d\n", (int)sizeof(s3));
  printf("strlen(s3) = %d\n", (int)strlen(s3));
  helper("s3", s3);
  printf("sizeof(s4) = %d\n", (int)sizeof(s4));
  printf("strlen(s4) = %d\n", (int)strlen(s4));
  helper("s4", s4);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x80,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xe95(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1060 <helper@plt>
lea    0xe7c(%rip),%rdi
mov    $0x40,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1060 <helper@plt>
lea    0xe5d(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x68(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x68(%rbp),%rsi
lea    0xe4f(%rip),%rdi
call   1060 <helper@plt>
lea    0xe46(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x70(%rbp),%rsi
lea    0xe38(%rip),%rdi
call   1060 <helper@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
mov    $0x80,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xeb8(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xeae(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
mov    %rbx,%rsi
call   1060 <helper@plt>
lea    0xea3(%rip),%rdi
mov    $0x40,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xe96(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe90(%rip),%rdi
mov    %rbx,%rsi
call   1060 <helper@plt>
lea    0xe84(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe82(%rip),%rdi
mov    $0x10,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe80(%rip),%rdi
lea    0xdf2(%rip),%rsi
call   1060 <helper@plt>
lea    0xe70(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xe66(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe67(%rip),%rdi
mov    %rbx,%rsi
call   1060 <helper@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"this is a string\00"
@.str.1 = [17 x i8] c"sizeof(s1) = %d\0A\00"
@.str.2 = [17 x i8] c"strlen(s1) = %d\0A\00"
@.str.3 = [3 x i8] c"s1\00"
@.str.4 = [17 x i8] c"sizeof(s2) = %d\0A\00"
@.str.5 = [17 x i8] c"strlen(s2) = %d\0A\00"
@.str.6 = [10 x i8] c"s2: \22%s\22\0A\00"
@.str.7 = [3 x i8] c"s2\00"
@.str.8 = [17 x i8] c"sizeof(s3) = %d\0A\00"
@.str.9 = [17 x i8] c"strlen(s3) = %d\0A\00"
@.str.10 = [3 x i8] c"s3\00"
@.str.11 = [17 x i8] c"sizeof(s4) = %d\0A\00"
@.str.12 = [17 x i8] c"strlen(s4) = %d\0A\00"
@.str.13 = [3 x i8] c"s4\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [64 x i8]
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i8* @malloc(i32 128)
store i8* %10, i8** %6
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %8
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
store i8* %11, i8** %9
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 8)
%13 = load i8*, i8** %6
%14 = call i64 @strlen(i8* %13)
%15 = trunc i64 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i8*, i8** %6
%18 = call i32 @helper(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 64)
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%21 = call i64 @strlen(i8* %20)
%22 = trunc i64 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%27 = call i32 @helper(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 8)
%29 = load i8*, i8** %8
%30 = call i64 @strlen(i8* %29)
%31 = trunc i64 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %31)
%33 = load i8*, i8** %8
%34 = call i32 @helper(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i32 8)
%36 = load i8*, i8** %9
%37 = call i64 @strlen(i8* %36)
%38 = trunc i64 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0), i32 %38)
%40 = load i8*, i8** %9
%41 = call i32 @helper(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"this is a string\00"
@.str.1 = [17 x i8] c"sizeof(s1) = %d\0A\00"
@.str.2 = [17 x i8] c"strlen(s1) = %d\0A\00"
@.str.3 = [3 x i8] c"s1\00"
@.str.4 = [17 x i8] c"sizeof(s2) = %d\0A\00"
@.str.5 = [17 x i8] c"strlen(s2) = %d\0A\00"
@.str.6 = [10 x i8] c"s2: \22%s\22\0A\00"
@.str.7 = [3 x i8] c"s2\00"
@.str.8 = [17 x i8] c"sizeof(s3) = %d\0A\00"
@.str.9 = [17 x i8] c"strlen(s3) = %d\0A\00"
@.str.10 = [3 x i8] c"s3\00"
@.str.11 = [17 x i8] c"sizeof(s4) = %d\0A\00"
@.str.12 = [17 x i8] c"strlen(s4) = %d\0A\00"
@.str.13 = [3 x i8] c"s4\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [64 x i8]
%4 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 8)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %4)
%8 = trunc i64 %7 to i32
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = tail call i32 @helper(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 64)
%12 = call i64 @strlen(i8* %5)
%13 = trunc i64 %12 to i32
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%16 = call i32 @helper(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %5)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 8)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 16)
%19 = call i32 @helper(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i32 8)
%21 = call i64 @strlen(i8* %5)
%22 = trunc i64 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0), i32 %22)
%24 = call i32 @helper(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %5)
ret i32 0
}