#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 */
scalar_t__ errno;
int /*<<< orphan*/ execlp(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
char *strerror(scalar_t__);
int main() {
  execlp("ls", "ls", NULL);
  printf("hurr\n");
  execlp("ls", "ls", NULL);
  if (errno) {
    printf("Error : %s", strerror(errno));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    %rsi,%rdi
call   1040 <execlp@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe99(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    %rsi,%rdi
call   1040 <execlp@plt>
mov    0x2e66(%rip),%rax
cmpq   $0x0,(%rax)
je     11a4 <main+0x74>
mov    0x2e55(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    %rax,%rsi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rbx
mov    %rbx,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1050 <execlp@plt>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1050 <execlp@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     1193 <main+0x53>
call   1060 <strerror@plt>
lea    0xe7a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"ls\00"
@.str.1 = [6 x i8] c"hurr\0A\00"
@errno = global i64 0
@.str.2 = [11 x i8] c"Error : %s\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null)
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null)
%5 = load i64, i64* @errno
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = load i64, i64* @errno
%9 = call i8* @strerror(i64 %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %7, %0
%12 = load i32, i32* %1
ret i32 %12
}

LLVM IR (-O2):
@.str = [3 x i8] c"ls\00"
@errno = global i64 0
@.str.2 = [11 x i8] c"Error : %s\00"
@str = [5 x i8] c"hurr\00"
define i32 @main() {
%1 = tail call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null)
%4 = load i64, i64* @errno
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = tail call i8* @strerror(i64 %4)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %6, %0
ret i32 0
}