#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*/ execvp(char *, char **);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcpy(char *, char *);
main() {
  char *arglist[3];
  arglist[0] = (char *)malloc(4 * sizeof(char));
  strcpy(arglist[0], "cal");
  arglist[1] = (char *)malloc(5 * sizeof(char));
  strcpy(arglist[1], "2012");
  arglist[2] = NULL;
  execvp("cal", arglist);
  printf("This statement is not executed if execvp succeeds.\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1030 <strcpy@plt>
mov    $0x5,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcpy@plt>
movq   $0x0,-0x10(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe69(%rip),%rdi
call   1060 <execvp@plt>
lea    0xe66(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,(%rsp)
lea    0xea6(%rip),%rbx
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    $0x5,%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%rsp)
lea    0xe89(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
movq   $0x0,0x10(%rsp)
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <execvp@plt>
lea    0xe6b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"cal\00"
@.str.1 = [5 x i8] c"2012\00"
@.str.2 = [52 x i8] c"This statement is not executed if execvp succeeds.\0A\00"
define i32 @main() {
%1 = alloca [3 x i8*]
%2 = call i64 @malloc(i32 4)
%3 = inttoptr i64 %2 to i8*
%4 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
store i8* %3, i8** %4
%5 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
%6 = load i8*, i8** %5
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = call i64 @malloc(i32 5)
%9 = inttoptr i64 %8 to i8*
%10 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 1
store i8* %9, i8** %10
%11 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 2
store i8* null, i8** %14
%15 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
%16 = call i32 @execvp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"cal\00"
@.str.1 = [5 x i8] c"2012\00"
@str = [51 x i8] c"This statement is not executed if execvp succeeds.\00"
define i32 @main() {
%1 = alloca [3 x i8*]
%2 = bitcast [3 x i8*]* %1 to i8*
%3 = tail call i64 @malloc(i32 4)
%4 = inttoptr i64 %3 to i8*
%5 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
store i8* %4, i8** %5
%6 = tail call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = tail call i64 @malloc(i32 5)
%8 = inttoptr i64 %7 to i8*
%9 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 1
store i8* %8, i8** %9
%10 = tail call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 2
store i8* null, i8** %11
%12 = call i32 @execvp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %5)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
ret i32 0
}