#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
void print_picks(int item, int size, int *weights, int **picks, FILE *arquivo) {
  while (item >= 0) {
    if (picks[item][size] == 1) {
      fprintf(arquivo, "%d\n", item);
      size = weights[item];
      item--;
    } else {
      item--;
    }
  }
}


x86 assembly (clang, -O0):
<print_picks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     118b <print_picks+0x7b>
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x8(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    117d <print_picks+0x6d>
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xea4(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1186 <print_picks+0x76>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    112a <print_picks+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_picks>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edi,%edi
js     116c <print_picks+0x5c>
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdx,%r15
mov    %edi,%ebx
lea    0xed1(%rip),%r13
jmp    114c <print_picks+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rbx),%rax
test   %rbx,%rbx
mov    %rax,%rbx
jle    116c <print_picks+0x5c>
mov    (%r12,%rbx,8),%rax
movslq %esi,%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    1140 <print_picks+0x30>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1030 <fprintf@plt>
mov    (%r15,%rbx,4),%esi
jmp    1140 <print_picks+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define void @print_picks(i32 %0, i32 %1, i32* %2, i32** %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32**
%10 = alloca i32*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store i32** %3, i32*** %9
store i32* %4, i32** %10
br label %11
11: ; preds = %39, %5
%12 = load i32, i32* %6
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %40
14: ; preds = %11
%15 = load i32**, i32*** %9
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32*, i32** %15, i64 %17
%19 = load i32*, i32** %18
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %36
25: ; preds = %14
%26 = load i32*, i32** %10
%27 = load i32, i32* %6
%28 = call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = load i32*, i32** %8
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
store i32 %33, i32* %7
%34 = load i32, i32* %6
%35 = add nsw i32 %34, -1
store i32 %35, i32* %6
br label %39
36: ; preds = %14
%37 = load i32, i32* %6
%38 = add nsw i32 %37, -1
store i32 %38, i32* %6
br label %39
39: ; preds = %36, %25
br label %11
40: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @print_picks(i32 %0, i32 %1, i32* nocapture %2, i32** nocapture %3, i32* nocapture %4) {
%6 = icmp sgt i32 %0, -1
br i1 %6, label %7, label %27
7: ; preds = %5
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %7, %23
%10 = phi i64 [ %8, %7 ], [ %25, %23 ]
%11 = phi i32 [ %1, %7 ], [ %24, %23 ]
%12 = getelementptr inbounds i32*, i32** %3, i64 %10
%13 = load i32*, i32** %12
%14 = sext i32 %11 to i64
%15 = getelementptr inbounds i32, i32* %13, i64 %14
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %23
18: ; preds = %9
%19 = trunc i64 %10 to i32
%20 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds i32, i32* %2, i64 %10
%22 = load i32, i32* %21
br label %23
23: ; preds = %9, %18
%24 = phi i32 [ %22, %18 ], [ %11, %9 ]
%25 = add nsw i64 %10, -1
%26 = icmp sgt i64 %10, 0
br i1 %26, label %9, label %27
27: ; preds = %23, %5
ret void
}