#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 zip_error {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ _zip_error_get(struct zip_error const *, int *, int *);
int errno;
int zip_error_get_sys_type(int);
void set_error(int *zep, const struct zip_error *err, int ze) {
  int se;
  if (err) {
    _zip_error_get(err, &ze, &se);
    if (zip_error_get_sys_type(ze) == 1)
      errno = se;
  }
  if (zep)
    *zep = ze;
}


x86 assembly (clang, -O0):
<set_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1171 <set_error+0x51>
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <_zip_error_get@plt>
mov    -0x14(%rbp),%edi
call   1040 <zip_error_get_sys_type@plt>
cmp    $0x1,%eax
jne    116c <set_error+0x4c>
mov    -0x18(%rbp),%ecx
mov    0x2e76(%rip),%rax
mov    %ecx,(%rax)
jmp    1171 <set_error+0x51>
cmpq   $0x0,-0x8(%rbp)
je     1185 <set_error+0x65>
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_error>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %edx,0x8(%rsp)
test   %rsi,%rsi
je     1161 <set_error+0x41>
lea    0x8(%rsp),%rax
lea    0xc(%rsp),%rdx
mov    %rsi,%rdi
mov    %rax,%rsi
call   1030 <_zip_error_get@plt>
mov    0x8(%rsp),%edi
call   1040 <zip_error_get_sys_type@plt>
cmp    $0x1,%eax
jne    1161 <set_error+0x41>
mov    0xc(%rsp),%eax
mov    0x2e81(%rip),%rcx
mov    %eax,(%rcx)
test   %rbx,%rbx
je     116c <set_error+0x4c>
mov    0x8(%rsp),%eax
mov    %eax,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.zip_error = type { i32 }
@errno = global i32 0
define void @set_error(i32* %0, %struct.zip_error* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca %struct.zip_error*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store %struct.zip_error* %1, %struct.zip_error** %5
store i32 %2, i32* %6
%8 = load %struct.zip_error*, %struct.zip_error** %5
%9 = icmp ne %struct.zip_error* %8, null
br i1 %9, label %10, label %19
10: ; preds = %3
%11 = load %struct.zip_error*, %struct.zip_error** %5
%12 = call i32 @_zip_error_get(%struct.zip_error* %11, i32* %6, i32* %7)
%13 = load i32, i32* %6
%14 = call i32 @zip_error_get_sys_type(i32 %13)
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = load i32, i32* %7
store i32 %17, i32* @errno
br label %18
18: ; preds = %16, %10
br label %19
19: ; preds = %18, %3
%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* %6
%24 = load i32*, i32** %4
store i32 %23, i32* %24
br label %25
25: ; preds = %22, %19
ret void
}

LLVM IR (-O2):
%struct.zip_error = type { i32 }
@errno = global i32 0
define void @set_error(i32* writeonly %0, %struct.zip_error* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
store i32 %2, i32* %4
%6 = bitcast i32* %5 to i8*
%7 = icmp eq %struct.zip_error* %1, null
br i1 %7, label %15, label %8
8: ; preds = %3
%9 = call i32 @_zip_error_get(%struct.zip_error* %1, i32* %4, i32* %5)
%10 = load i32, i32* %4
%11 = call i32 @zip_error_get_sys_type(i32 %10)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = load i32, i32* %5
store i32 %14, i32* @errno
br label %15
15: ; preds = %8, %13, %3
%16 = icmp eq i32* %0, null
br i1 %16, label %19, label %17
17: ; preds = %15
%18 = load i32, i32* %4
store i32 %18, i32* %0
br label %19
19: ; preds = %17, %15
ret void
}