#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 */
scalar_t__ calloc(long, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int *ivector(long n) {
  int *v;
  if (n < 1) {
    fprintf(stderr, "ivector: parameter n must be > 0\n");
    return NULL;
  }
  if (!(v = (int *)calloc(n, sizeof(int))))
    fprintf(stderr, "ivector: out of memory\n");
  return v;
}


x86 assembly (clang, -O0):
<ivector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x1,-0x10(%rbp)
jge    1159 <ivector+0x39>
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    0xeb9(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1192 <ivector+0x72>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    118a <ivector+0x6a>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ivector>:
push   %rbx
test   %rdi,%rdi
jle    1141 <ivector+0x21>
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1158 <ivector+0x38>
lea    0xee3(%rip),%rsi
jmp    114a <ivector+0x2a>
lea    0xeb8(%rip),%rsi
xor    %ebx,%ebx
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
call   1040 <fprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"ivector: parameter n must be > 0\0A\00"
@.str.1 = [24 x i8] c"ivector: out of memory\0A\00"
define i32* @ivector(i64 %0) {
%2 = alloca i32*
%3 = alloca i64
%4 = alloca i32*
store i64 %0, i64* %3
%5 = load i64, i64* %3
%6 = icmp slt i64 %5, 1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32* null, i32** %2
br label %20
10: ; preds = %1
%11 = load i64, i64* %3
%12 = call i64 @calloc(i64 %11, i32 4)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %4
%14 = icmp ne i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %10
%19 = load i32*, i32** %4
store i32* %19, i32** %2
br label %20
20: ; preds = %18, %7
%21 = load i32*, i32** %2
ret i32* %21
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"ivector: parameter n must be > 0\0A\00"
@.str.1 = [24 x i8] c"ivector: out of memory\0A\00"
define i32* @ivector(i64 %0) {
%2 = icmp slt i64 %0, 1
br i1 %2, label %7, label %3
3: ; preds = %1
%4 = tail call i64 @calloc(i64 %0, i32 4)
%5 = inttoptr i64 %4 to i32*
%6 = icmp eq i64 %4, 0
br i1 %6, label %7, label %12
7: ; preds = %3, %1
%8 = phi i8* [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), %3 ]
%9 = phi i32* [ null, %1 ], [ %5, %3 ]
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* %8)
br label %12
12: ; preds = %7, %3
%13 = phi i32* [ %5, %3 ], [ %9, %7 ]
ret i32* %13
}