#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 long pid_t;

/* Variables and functions */
int /*<<< orphan*/ chdir(char *);
int /*<<< orphan*/ execlp(char const *, char const *, char const *, char *);
int /*<<< orphan*/ exit(int);
long fork();
int /*<<< orphan*/ umask(int /*<<< orphan*/);
pid_t sdialog_call(const char *path, const char *msg) {
  pid_t pid;
  ;
  if ((pid = fork()) < 0) {
    ;
    return 0L;
  }
  if (pid == 0) {
    ;
    ;
    umask(0);
    chdir("/");
    ;
    execlp(path, path, msg, (char *)0);
    ;
    exit(1);
  };
  return pid;
}


x86 assembly (clang, -O0):
<sdialog_call>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jge    1182 <sdialog_call+0x32>
movq   $0x0,-0x8(%rbp)
jmp    11c7 <sdialog_call+0x77>
cmpq   $0x0,-0x20(%rbp)
jne    11bf <sdialog_call+0x6f>
xor    %edi,%edi
call   1040 <umask@plt>
lea    0xe65(%rip),%rdi
call   1030 <chdir@plt>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1060 <execlp@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sdialog_call>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
js     1195 <sdialog_call+0x45>
jne    1197 <sdialog_call+0x47>
xor    %edi,%edi
call   1040 <umask@plt>
lea    0xe8a(%rip),%rdi
call   1030 <chdir@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1060 <execlp@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define i64 @sdialog_call(i8* %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = call i64 (...) @fork()
store i64 %7, i64* %6
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i64 0, i64* %3
br label %23
10: ; preds = %2
%11 = load i64, i64* %6
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = call i32 @umask(i32 0)
%15 = call i32 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = load i8*, i8** %4
%17 = load i8*, i8** %4
%18 = load i8*, i8** %5
%19 = call i32 @execlp(i8* %16, i8* %17, i8* %18, i8* null)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %10
%22 = load i64, i64* %6
store i64 %22, i64* %3
br label %23
23: ; preds = %21, %9
%24 = load i64, i64* %3
ret i64 %24
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define i64 @sdialog_call(i8* %0, i8* %1) {
%3 = tail call i64 (...) @fork()
%4 = icmp slt i64 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = icmp eq i64 %3, 0
br i1 %6, label %7, label %12
7: ; preds = %5
%8 = tail call i32 @umask(i32 0)
%9 = tail call i32 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @execlp(i8* %0, i8* %0, i8* %1, i8* null)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %5, %2
%13 = phi i64 [ 0, %2 ], [ %3, %5 ]
ret i64 %13
}