#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int assignment2index(int *, int);
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ index2assignment(int, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int values[4];
  int i;
  int index;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <index>\n", argv[0]);
    return EXIT_FAILURE;
  }
  index = atoi(argv[1]);
  index2assignment(index, values, 4);
  if (index != assignment2index(values, 4)) {
    printf("assignment2index() does not work\n");
  }
  printf("%d = [ ", index);
  for (i = 0; i < 4; ++i) {
    printf("%d ", values[i]);
  }
  printf("]\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119d <main+0x4d>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    124d <main+0xfd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1050 <index2assignment@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1060 <assignment2index@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
je     11ed <main+0x9d>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    1233 <main+0xe3>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1205 <main+0xb5>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jne    120d <main+0xad>
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
mov    %rsp,%r14
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1060 <index2assignment@plt>
mov    %r14,%rdi
mov    $0x4,%esi
call   1070 <assignment2index@plt>
cmp    %eax,%ebx
je     11aa <main+0x4a>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe62(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%esi
lea    0xe57(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dc5(%rip),%rax
jmp    122c <main+0xcc>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xde0(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: %s <index>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [34 x i8] c"assignment2index() does not work\0A\00"
@.str.2 = [8 x i8] c"%d = [ \00"
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [3 x i8] c"]\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i32]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
store i32 %17, i32* %3
br label %50
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%25 = call i32 @index2assignment(i32 %23, i32* %24, i32 4)
%26 = load i32, i32* %8
%27 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%28 = call i32 @assignment2index(i32* %27, i32 4)
%29 = icmp ne i32 %26, %28
br i1 %29, label %30, label %32
30: ; preds = %18
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %18
%33 = load i32, i32* %8
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %33)
store i32 0, i32* %7
br label %35
35: ; preds = %44, %32
%36 = load i32, i32* %7
%37 = icmp slt i32 %36, 4
br i1 %37, label %38, label %47
38: ; preds = %35
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %38
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
br label %35
47: ; preds = %35
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%49 = load i32, i32* @EXIT_SUCCESS
store i32 %49, i32* %3
br label %50
50: ; preds = %47, %11
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: %s <index>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [8 x i8] c"%d = [ \00"
@.str.3 = [4 x i8] c"%d \00"
@EXIT_SUCCESS = global i32 0
@str = [2 x i8] c"]\00"
@str.5 = [33 x i8] c"assignment2index() does not work\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i32]
%4 = bitcast [4 x i32]* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %34
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%15 = call i32 @index2assignment(i32 %13, i32* %14, i32 4)
%16 = call i32 @assignment2index(i32* %14, i32 4)
%17 = icmp eq i32 %13, %16
br i1 %17, label %20, label %18
18: ; preds = %10
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.5, i64 0, i64 0))
br label %20
20: ; preds = %18, %10
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%22 = load i32, i32* %14
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %34
34: ; preds = %20, %6
%35 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_SUCCESS, %20 ]
%36 = load i32, i32* %35
ret i32 %36
}