#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*/ free(char *);
char *malloc(size_t);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ sysctlbyname(char *, char *, size_t *, int /*<<< orphan*/ *,
                                int /*<<< orphan*/);
int NWIsDeviceIPadMini() {
  int result = 0;
  size_t size;
  sysctlbyname("hw.machine", NULL, &size, NULL, 0);
  char *machine = malloc(size + 1);
  sysctlbyname("hw.machine", machine, &size, NULL, 0);
  machine[size] = 0;
  if (strcmp(machine, "iPad2,5") == 0 || strcmp(machine, "iPad2,6") == 0 ||
      strcmp(machine, "iPad2,7") == 0) {
    result = 1;
  }
  free(machine);
  return result;
}


x86 assembly (clang, -O0):
<NWIsDeviceIPadMini>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x10(%rbp),%rdx
xor    %r8d,%r8d
mov    %rcx,%rsi
call   1060 <sysctlbyname@plt>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe7b(%rip),%rdi
lea    -0x10(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
xor    %r8d,%r8d
call   1060 <sysctlbyname@plt>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11ef <NWIsDeviceIPadMini+0xaf>
mov    -0x18(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11ef <NWIsDeviceIPadMini+0xaf>
mov    -0x18(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f6 <NWIsDeviceIPadMini+0xb6>
movl   $0x1,-0x4(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NWIsDeviceIPadMini>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb1(%rip),%r14
lea    0x8(%rsp),%rbp
mov    %r14,%rdi
xor    %esi,%esi
mov    %rbp,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <sysctlbyname@plt>
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
mov    %rbp,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <sysctlbyname@plt>
mov    0x8(%rsp),%rax
movb   $0x0,(%rbx,%rax,1)
lea    0xe71(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d1 <NWIsDeviceIPadMini+0x91>
lea    0xe65(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d1 <NWIsDeviceIPadMini+0x91>
lea    0xe59(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    11d6 <NWIsDeviceIPadMini+0x96>
mov    $0x1,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"hw.machine\00"
@.str.1 = [8 x i8] c"iPad2,5\00"
@.str.2 = [8 x i8] c"iPad2,6\00"
@.str.3 = [8 x i8] c"iPad2,7\00"
define i32 @NWIsDeviceIPadMini() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i32 @sysctlbyname(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* null, i64* %2, i32* null, i32 0)
%5 = load i64, i64* %2
%6 = add i64 %5, 1
%7 = call i8* @malloc(i64 %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @sysctlbyname(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8, i64* %2, i32* null, i32 0)
%10 = load i8*, i8** %3
%11 = load i64, i64* %2
%12 = getelementptr inbounds i8, i8* %10, i64 %11
store i8 0, i8* %12
%13 = load i8*, i8** %3
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %0
%17 = load i8*, i8** %3
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20, %16, %0
store i32 1, i32* %1
br label %25
25: ; preds = %24, %20
%26 = load i8*, i8** %3
%27 = call i32 @free(i8* %26)
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [11 x i8] c"hw.machine\00"
@.str.1 = [8 x i8] c"iPad2,5\00"
@.str.2 = [8 x i8] c"iPad2,6\00"
@.str.3 = [8 x i8] c"iPad2,7\00"
define i32 @NWIsDeviceIPadMini() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i32 @sysctlbyname(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* null, i64* %1, i32* null, i32 0)
%4 = load i64, i64* %1
%5 = add i64 %4, 1
%6 = call i8* @malloc(i64 %5)
%7 = call i32 @sysctlbyname(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %6, i64* %1, i32* null, i32 0)
%8 = load i64, i64* %1
%9 = getelementptr inbounds i8, i8* %6, i64 %8
store i8 0, i8* %9
%10 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %0
%13 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15, %12, %0
br label %19
19: ; preds = %18, %15
%20 = phi i32 [ 1, %18 ], [ 0, %15 ]
%21 = call i32 @free(i8* %6)
ret i32 %20
}