#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 canvasGetCost(int);
char *getenv(char *);
int /*<<< orphan*/ printf(char *, ...);
long strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(void) {
  printf("Content-Type: text/plain;charset=us-ascii\n\n");
  char *value = NULL;
  long number = 0;
  value = getenv("NB");
  if (!value)
    return 0;
  number = strtol(value, NULL, 0);
  if (!number)
    return 0;
  printf("%i", canvasGetCost((int)number));
end:
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xeb8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1194 <main+0x54>
movl   $0x0,-0x4(%rbp)
jmp    11e0 <main+0xa0>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11be <main+0x7e>
movl   $0x0,-0x4(%rbp)
jmp    11e0 <main+0xa0>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
call   1060 <canvasGetCost@plt>
mov    %eax,%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeae(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9c(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1196 <main+0x46>
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtol@plt>
test   %rax,%rax
je     1196 <main+0x46>
mov    %eax,%edi
call   1070 <canvasGetCost@plt>
lea    0xe76(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Content-Type: text/plain;charset=us-ascii\0A\0A\00"
@.str.1 = [3 x i8] c"NB\00"
@.str.2 = [3 x i8] c"%i\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %2
store i64 0, i64* %3
%5 = call i8* @getenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %0
store i32 0, i32* %1
br label %21
9: ; preds = %0
%10 = load i8*, i8** %2
%11 = call i64 @strtol(i8* %10, i32* null, i32 0)
store i64 %11, i64* %3
%12 = load i64, i64* %3
%13 = icmp ne i64 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %9
store i32 0, i32* %1
br label %21
15: ; preds = %9
%16 = load i64, i64* %3
%17 = trunc i64 %16 to i32
%18 = call i32 @canvasGetCost(i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %15
store i32 0, i32* %1
br label %21
21: ; preds = %20, %14, %8
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"NB\00"
@.str.2 = [3 x i8] c"%i\00"
@str = [43 x i8] c"Content-Type: text/plain;charset=us-ascii\0A\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %11, label %4
4: ; preds = %0
%5 = tail call i64 @strtol(i8* nocapture %2, i32* null, i32 0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = trunc i64 %5 to i32
%9 = tail call i32 @canvasGetCost(i32 %8)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %4, %0, %7
ret i32 0
}