#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*/ pwd;

/* Variables and functions */
int /*<<< orphan*/ MAXPATHLEN;
int /*<<< orphan*/ execl(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ getcwd(char *, int);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  char *cmd;
  char pwd[MAXPATHLEN + 1];
  getcwd(pwd, sizeof(pwd));
  cmd = malloc(sizeof(char) * (strlen(pwd) + 1 + strlen("openurl.rb") + 1));
  sprintf(cmd, "%s/%s", pwd, "openurl.rb");
  execl(cmd, cmd, NULL);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    %eax,%esi
call   1040 <getcwd@plt>
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
lea    0xe4e(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    -0x30(%rbp),%rdx
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe2a(%rip),%rsi
lea    0xe18(%rip),%rcx
call   1060 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <execl@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e87(%rip),%rax
mov    (%rax),%esi
add    $0x1,%esi
mov    %rsp,%rbx
lea    0xf(%rsi),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1040 <getcwd@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r14d
lea    0xe6f(%rip),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
lea    (%r14,%rax,1),%edi
add    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    0xe5c(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1070 <execl@plt>
mov    $0x1,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MAXPATHLEN = global i32 0
@.str = [11 x i8] c"openurl.rb\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @MAXPATHLEN
%10 = add nsw i32 %9, 1
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %7
%13 = alloca i8, i64 %11
store i64 %11, i64* %8
%14 = trunc i64 %11 to i32
%15 = call i32 @getcwd(i8* %13, i32 %14)
%16 = call i32 @strlen(i8* %13)
%17 = add nsw i32 %16, 1
%18 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%19 = add nsw i32 %17, %18
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = mul i64 1, %21
%23 = trunc i64 %22 to i32
%24 = call i8* @malloc(i32 %23)
store i8* %24, i8** %6
%25 = load i8*, i8** %6
%26 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%27 = load i8*, i8** %6
%28 = load i8*, i8** %6
%29 = call i32 @execl(i8* %27, i8* %28, i32* null)
store i32 1, i32* %3
%30 = load i8*, i8** %7
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@MAXPATHLEN = global i32 0
@.str = [11 x i8] c"openurl.rb\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @MAXPATHLEN
%4 = add nsw i32 %3, 1
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = call i32 @getcwd(i8* %6, i32 %4)
%8 = call i32 @strlen(i8* %6)
%9 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%10 = add i32 %8, 2
%11 = add i32 %10, %9
%12 = call i8* @malloc(i32 %11)
%13 = call i32 @sprintf(i8* dereferenceable(1) %12, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @execl(i8* %12, i8* %12, i32* null)
ret i32 1
}