#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 compareints(int *, int *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ shuffle(int, char **);
int /*<<< orphan*/ stderr;
int sum(int, int *);
int main(int argc, char *argv[]) {
  if (argc == 1) {
    fprintf(stderr, "Please provide some arguments and we'll shuffle them\n");
    exit(1);
  }
  shuffle(argc, argv);
  for (int i = 0; i < argc; i++)
    printf("%s\n", argv[i]);
  int arr[5] = {2, 4, 6, 8, 10};
  int s = sum(5, arr);
  if (s != 30)
    printf("The array should sum to 30 but sums to %d\n", s);
  int a = 3;
  for (int b = 1; b < 6; b++) {
    printf("Comparing %d to %d resulted in %d\n", a, b, compareints(&a, &b));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    119f <main+0x3f>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <shuffle@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e6 <main+0x86>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b2 <main+0x52>
mov    0xea3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe9e(%rip),%eax
mov    %eax,-0x20(%rbp)
lea    -0x30(%rbp),%rsi
mov    $0x5,%edi
call   1060 <sum@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x1e,-0x34(%rbp)
je     1231 <main+0xd1>
mov    -0x34(%rbp),%esi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x3,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
cmpl   $0x6,-0x3c(%rbp)
jge    1286 <main+0x126>
mov    -0x38(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
lea    -0x38(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
call   1070 <compareints@plt>
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    %eax,%ecx
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    123f <main+0xdf>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
cmp    $0x1,%edi
je     128e <main+0x11e>
mov    %rsi,%r14
mov    %edi,%ebp
call   1040 <shuffle@plt>
test   %ebp,%ebp
jle    11b2 <main+0x42>
mov    %ebp,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
call   1030 <puts@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11a0 <main+0x30>
mov    0xee8(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xecd(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    $0x5,%edi
call   1070 <sum@plt>
cmp    $0x1e,%eax
je     11ec <main+0x7c>
lea    0xe53(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x3,0xc(%rsp)
movl   $0x1,0x8(%rsp)
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1080 <compareints@plt>
lea    0xe4f(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%eax
lea    0x1(%rax),%ebp
mov    %ebp,0x8(%rsp)
cmp    $0x4,%eax
jg     127f <main+0x10f>
lea    0xc(%rsp),%r14
lea    0x8(%rsp),%r15
lea    0xe1b(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    0xc(%rsp),%ebx
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <compareints@plt>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%eax
lea    0x1(%rax),%ebp
mov    %ebp,0x8(%rsp)
cmp    $0x5,%eax
jl     1250 <main+0xe0>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
lea    0xd62(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [54 x i8] c"Please provide some arguments and we'll shuffle them\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@__const.main.arr = [5 x i32] [i32 2, i32 4, i32 6, i32 8, i32 10]
@.str.2 = [43 x i8] c"The array should sum to 30 but sums to %d\0A\00"
@.str.3 = [35 x i8] c"Comparing %d to %d resulted in %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [5 x i32]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @shuffle(i32 %18, i8** %19)
store i32 0, i32* %6
br label %21
21: ; preds = %32, %17
%22 = load i32, i32* %6
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %35
25: ; preds = %21
%26 = load i8**, i8*** %5
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %25
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %21
35: ; preds = %21
%36 = bitcast [5 x i32]* %7 to i8*
%37 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 0
%38 = call i32 @sum(i32 5, i32* %37)
store i32 %38, i32* %8
%39 = load i32, i32* %8
%40 = icmp ne i32 %39, 30
br i1 %40, label %41, label %44
41: ; preds = %35
%42 = load i32, i32* %8
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %41, %35
store i32 3, i32* %9
store i32 1, i32* %10
br label %45
45: ; preds = %53, %44
%46 = load i32, i32* %10
%47 = icmp slt i32 %46, 6
br i1 %47, label %48, label %56
48: ; preds = %45
%49 = load i32, i32* %9
%50 = load i32, i32* %10
%51 = call i32 @compareints(i32* %9, i32* %10)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %49, i32 %50, i32 %51)
br label %53
53: ; preds = %48
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
br label %45
56: ; preds = %45
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [54 x i8] c"Please provide some arguments and we'll shuffle them\0A\00"
@__const.main.arr = [5 x i32] [i32 2, i32 4, i32 6, i32 8, i32 10]
@.str.2 = [43 x i8] c"The array should sum to 30 but sums to %d\0A\00"
@.str.3 = [35 x i8] c"Comparing %d to %d resulted in %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [5 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = icmp eq i32 %0, 1
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = tail call i32 @shuffle(i32 %0, i8** %1)
%13 = icmp sgt i32 %0, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = zext i32 %0 to i64
br label %21
16: ; preds = %21, %11
%17 = bitcast [5 x i32]* %3 to i8*
%18 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%19 = call i32 @sum(i32 5, i32* %18)
%20 = icmp eq i32 %19, 30
br i1 %20, label %30, label %28
21: ; preds = %14, %21
%22 = phi i64 [ 0, %14 ], [ %26, %21 ]
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
%25 = tail call i32 @puts(i8* dereferenceable(1) %24)
%26 = add nuw nsw i64 %22, 1
%27 = icmp eq i64 %26, %15
br i1 %27, label %16, label %21
28: ; preds = %16
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %19)
br label %30
30: ; preds = %28, %16
%31 = bitcast i32* %4 to i8*
store i32 3, i32* %4
%32 = bitcast i32* %5 to i8*
store i32 1, i32* %5
%33 = call i32 @compareints(i32* %4, i32* %5)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 1, i32 %33)
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
%37 = icmp slt i32 %35, 5
br i1 %37, label %39, label %38
38: ; preds = %39, %30
ret i32 0
39: ; preds = %30, %39
%40 = phi i32 [ %45, %39 ], [ %36, %30 ]
%41 = load i32, i32* %4
%42 = call i32 @compareints(i32* %4, i32* %5)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 %40, i32 %42)
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
%46 = icmp slt i32 %44, 5
br i1 %46, label %39, label %38
}