#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*/ cg_io_error(char *);
scalar_t__ cgio_path_add(char const *);
int /*<<< orphan*/ cgio_path_delete(int /*<<< orphan*/ *);
int cg_set_path(const char *path) {
  cgio_path_delete(NULL);
  if (path && *path) {
    if (cgio_path_add(path)) {
      cg_io_error("cgio_path_add");
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<cg_set_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <cgio_path_delete@plt>
cmpq   $0x0,-0x10(%rbp)
je     1190 <cg_set_path+0x60>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1190 <cg_set_path+0x60>
mov    -0x10(%rbp),%rdi
call   1030 <cgio_path_add@plt>
cmp    $0x0,%rax
je     118b <cg_set_path+0x5b>
lea    0xe86(%rip),%rdi
call   1040 <cg_io_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    1197 <cg_set_path+0x67>
jmp    1190 <cg_set_path+0x60>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cg_set_path>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %r14d,%r14d
xor    %edi,%edi
call   1050 <cgio_path_delete@plt>
test   %rbx,%rbx
je     116a <cg_set_path+0x3a>
cmpb   $0x0,(%rbx)
je     116a <cg_set_path+0x3a>
mov    %rbx,%rdi
call   1030 <cgio_path_add@plt>
test   %rax,%rax
je     116a <cg_set_path+0x3a>
lea    0xea1(%rip),%rdi
call   1040 <cg_io_error@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"cgio_path_add\00"
define i32 @cg_set_path(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = call i32 @cgio_path_delete(i32* null)
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %19
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i64 @cgio_path_add(i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @cg_io_error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %20
18: ; preds = %12
br label %19
19: ; preds = %18, %7, %1
store i32 0, i32* %2
br label %20
20: ; preds = %19, %16
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@.str = [14 x i8] c"cgio_path_add\00"
define i32 @cg_set_path(i8* %0) {
%2 = tail call i32 @cgio_path_delete(i32* null)
%3 = icmp eq i8* %0, null
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = tail call i64 @cgio_path_add(i8* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @cg_io_error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %1, %4, %7, %10
%13 = phi i32 [ 1, %10 ], [ 0, %7 ], [ 0, %4 ], [ 0, %1 ]
ret i32 %13
}