#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 atoi(int /*<<< orphan*/);
int /*<<< orphan*/ getenv(char *);
int /*<<< orphan*/ printf(char *);
int init(int *width, int *height, int *err) {
  if (!getenv("WIDTH") || !getenv("HEIGHT")) {
    printf("WIDTH or HEIGHT is not set\n");
    goto fail;
  }
  *width = atoi(getenv("WIDTH"));
  *height = atoi(getenv("HEIGHT"));
  *err = 0;
  return 0;
fail:
  *err = -1;
  return 0;
}


x86 assembly (clang, -O0):
<init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    0xeb5(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%eax
je     116e <init+0x3e>
lea    0xea6(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%eax
jne    117f <init+0x4f>
lea    0xe98(%rip),%rdi
call   1040 <printf@plt>
jmp    11cb <init+0x9b>
lea    0xe7a(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
lea    0xe65(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11dc <init+0xac>
mov    -0x20(%rbp),%rax
movl   $0xffffffff,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeb9(%rip),%rdi
call   1030 <getenv@plt>
test   %eax,%eax
je     1185 <init+0x55>
mov    %eax,%ebp
lea    0xead(%rip),%rdi
call   1030 <getenv@plt>
test   %eax,%eax
je     1185 <init+0x55>
mov    %ebp,%edi
call   1050 <atoi@plt>
mov    %eax,(%rbx)
lea    0xe94(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %eax,(%r14)
xor    %eax,%eax
jmp    1196 <init+0x66>
lea    0xe81(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
mov    %eax,(%r15)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"WIDTH\00"
@.str.1 = [7 x i8] c"HEIGHT\00"
@.str.2 = [28 x i8] c"WIDTH or HEIGHT is not set\0A\00"
define i32 @init(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%8 = call i32 @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = call i32 @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10, %3
%14 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %23
15: ; preds = %10
%16 = call i32 @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @atoi(i32 %16)
%18 = load i32*, i32** %5
store i32 %17, i32* %18
%19 = call i32 @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @atoi(i32 %19)
%21 = load i32*, i32** %6
store i32 %20, i32* %21
%22 = load i32*, i32** %7
store i32 0, i32* %22
store i32 0, i32* %4
br label %25
23: ; preds = %13
%24 = load i32*, i32** %7
store i32 -1, i32* %24
store i32 0, i32* %4
br label %25
25: ; preds = %23, %15
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
@.str = [6 x i8] c"WIDTH\00"
@.str.1 = [7 x i8] c"HEIGHT\00"
@str = [27 x i8] c"WIDTH or HEIGHT is not set\00"
define i32 @init(i32* nocapture writeonly %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = tail call i32 @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i32 @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6, %3
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %15
11: ; preds = %6
%12 = tail call i32 @atoi(i32 %4)
store i32 %12, i32* %0
%13 = tail call i32 @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @atoi(i32 %13)
store i32 %14, i32* %1
br label %15
15: ; preds = %9, %11
%16 = phi i32 [ -1, %9 ], [ 0, %11 ]
store i32 %16, i32* %2
ret i32 0
}