#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 */
unsigned int get_unum();
int /*<<< orphan*/ printf(char *);
int store_number(unsigned int *data) {
  unsigned int input = 0;
  int index = 0;
  printf(" Number: ");
  input = get_unum();
  printf(" Index: ");
  index = (int)get_unum();
  if (index % 3 == 0 || index > 100 || (input >> 24) == 0xb7) {
    printf(" *** ERROR! ***\n");
    printf("   This index is reserved for doom!\n");
    printf(" *** ERROR! ***\n");
    return 1;
  }
  data[index] = input;
  return 0;
}


x86 assembly (clang, -O0):
<store_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <get_unum@plt>
mov    %eax,-0x14(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <get_unum@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1195 <store_number+0x75>
cmpl   $0x64,-0x18(%rbp)
jg     1195 <store_number+0x75>
mov    -0x14(%rbp),%eax
shr    $0x18,%eax
cmp    $0xb7,%eax
jne    11c5 <store_number+0xa5>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11da <store_number+0xba>
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<store_number>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <get_unum@plt>
mov    %eax,%ebp
lea    0xeb8(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <get_unum@plt>
cmp    $0x64,%eax
jg     1199 <store_number+0x69>
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
mov    %eax,%edx
sub    %ecx,%edx
je     1199 <store_number+0x69>
mov    %ebp,%ecx
and    $0xff000000,%ecx
cmp    $0xb7000000,%ecx
je     1199 <store_number+0x69>
mov    %ebp,(%rbx,%rax,4)
xor    %eax,%eax
jmp    11c1 <store_number+0x91>
lea    0xe97(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe64(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c" Number: \00"
@.str.1 = [9 x i8] c" Index: \00"
@.str.2 = [17 x i8] c" *** ERROR! ***\0A\00"
@.str.3 = [37 x i8] c" This index is reserved for doom!\0A\00"
define i32 @store_number(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (...) @get_unum()
store i32 %7, i32* %4
%8 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (...) @get_unum()
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = srem i32 %10, 3
%12 = icmp eq i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %1
%14 = load i32, i32* %5
%15 = icmp sgt i32 %14, 100
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = load i32, i32* %4
%18 = lshr i32 %17, 24
%19 = icmp eq i32 %18, 183
br i1 %19, label %20, label %24
20: ; preds = %16, %13, %1
%21 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %2
br label %30
24: ; preds = %16
%25 = load i32, i32* %4
%26 = load i32*, i32** %3
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
store i32 %25, i32* %29
store i32 0, i32* %2
br label %30
30: ; preds = %24, %20
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [10 x i8] c" Number: \00"
@.str.1 = [9 x i8] c" Index: \00"
@str.4 = [36 x i8] c" This index is reserved for doom!\00"
@str.5 = [16 x i8] c" *** ERROR! ***\00"
define i32 @store_number(i32* nocapture writeonly %0) {
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (...) @get_unum()
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 (...) @get_unum()
%6 = srem i32 %5, 3
%7 = icmp eq i32 %6, 0
%8 = icmp sgt i32 %5, 100
%9 = or i1 %8, %7
%10 = and i32 %3, -16777216
%11 = icmp eq i32 %10, -1224736768
%12 = select i1 %9, i1 true, i1 %11
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.5, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.4, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.5, i64 0, i64 0))
br label %20
17: ; preds = %1
%18 = sext i32 %5 to i64
%19 = getelementptr inbounds i32, i32* %0, i64 %18
store i32 %3, i32* %19
br label %20
20: ; preds = %17, %13
%21 = phi i32 [ 1, %13 ], [ 0, %17 ]
ret i32 %21
}