#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 */
struct stat {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ chdir(char *);
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ parse_device_table(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror_msg_and_die(char *, char *);
int go(char *dname, FILE *devtable) {
  struct stat sb;
  if (lstat(dname, &sb)) {
    perror_msg_and_die("%s", dname);
  }
  if (chdir(dname))
    perror_msg_and_die("%s", dname);
  if (devtable)
    parse_device_table(devtable);
  return 0;
}


x86 assembly (clang, -O0):
<go>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <lstat@plt>
cmp    $0x0,%rax
je     1177 <go+0x37>
mov    -0x8(%rbp),%rsi
lea    0xe8e(%rip),%rdi
call   1050 <perror_msg_and_die@plt>
mov    -0x8(%rbp),%rdi
call   1030 <chdir@plt>
cmp    $0x0,%rax
je     119a <go+0x5a>
mov    -0x8(%rbp),%rsi
lea    0xe6b(%rip),%rdi
call   1050 <perror_msg_and_die@plt>
cmpq   $0x0,-0x10(%rbp)
je     11ae <go+0x6e>
mov    -0x10(%rbp),%rdi
call   1060 <parse_device_table@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<go>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rsi
call   1040 <lstat@plt>
test   %rax,%rax
je     1166 <go+0x26>
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
call   1050 <perror_msg_and_die@plt>
mov    %rbx,%rdi
call   1030 <chdir@plt>
test   %rax,%rax
je     1182 <go+0x42>
lea    0xe86(%rip),%rdi
mov    %rbx,%rsi
call   1050 <perror_msg_and_die@plt>
test   %r14,%r14
je     118f <go+0x4f>
mov    %r14,%rdi
call   1060 <parse_device_table@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [3 x i8] c"%s\00"
define i32 @go(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca %struct.stat
store i8* %0, i8** %3
store i32* %1, i32** %4
%6 = load i8*, i8** %3
%7 = call i64 @lstat(i8* %6, %struct.stat* %5)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i32 @perror_msg_and_die(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %9, %2
%13 = load i8*, i8** %3
%14 = call i64 @chdir(i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = call i32 @perror_msg_and_die(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %16, %12
%20 = load i32*, i32** %4
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32*, i32** %4
%24 = call i32 @parse_device_table(i32* %23)
br label %25
25: ; preds = %22, %19
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [3 x i8] c"%s\00"
define i32 @go(i8* %0, i32* %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = call i64 @lstat(i8* %0, %struct.stat* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @perror_msg_and_die(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %9
9: ; preds = %7, %2
%10 = tail call i64 @chdir(i8* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @perror_msg_and_die(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %14
14: ; preds = %12, %9
%15 = icmp eq i32* %1, null
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = tail call i32 @parse_device_table(i32* %1)
br label %18
18: ; preds = %16, %14
ret i32 0
}