#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;
  unsigned int index = 0;
  printf(" Number: ");
  input = get_unum();
  printf(" Index: ");
  index = get_unum();
  if (index % 3 == 0 || (input >> 24) == 0xb7) {
    printf(" *** ERROR! ***\n");
    printf("   This index is reserved for quend!\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
xor    %edx,%edx
div    %ecx
cmp    $0x0,%edx
je     118c <store_number+0x6c>
mov    -0x14(%rbp),%eax
shr    $0x18,%eax
cmp    $0xb7,%eax
jne    11bc <store_number+0x9c>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d0 <store_number+0xb0>
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
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>
imul   $0xaaaaaaab,%eax,%ecx
cmp    $0x55555556,%ecx
jb     1185 <store_number+0x55>
mov    %ebp,%ecx
and    $0xff000000,%ecx
cmp    $0xb7000000,%ecx
je     1185 <store_number+0x55>
mov    %eax,%eax
mov    %ebp,(%rbx,%rax,4)
xor    %eax,%eax
jmp    11ad <store_number+0x7d>
lea    0xeac(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe78(%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 = [38 x i8] c" This index is reserved for quend!\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 = urem i32 %10, 3
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %1
%14 = load i32, i32* %4
%15 = lshr i32 %14, 24
%16 = icmp eq i32 %15, 183
br i1 %16, label %17, label %21
17: ; preds = %13, %1
%18 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%20 = 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 %27
21: ; preds = %13
%22 = load i32, i32* %4
%23 = load i32*, i32** %3
%24 = load i32, i32* %5
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
store i32 %22, i32* %26
store i32 0, i32* %2
br label %27
27: ; preds = %21, %17
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@.str = [10 x i8] c" Number: \00"
@.str.1 = [9 x i8] c" Index: \00"
@str.4 = [37 x i8] c" This index is reserved for quend!\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 = urem i32 %5, 3
%7 = icmp eq i32 %6, 0
%8 = and i32 %3, -16777216
%9 = icmp eq i32 %8, -1224736768
%10 = select i1 %7, i1 true, i1 %9
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.5, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.4, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.5, i64 0, i64 0))
br label %18
15: ; preds = %1
%16 = zext i32 %5 to i64
%17 = getelementptr inbounds i32, i32* %0, i64 %16
store i32 %3, i32* %17
br label %18
18: ; preds = %15, %11
%19 = phi i32 [ 1, %11 ], [ 0, %15 ]
ret i32 %19
}