#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 && size >= 0) {
    if (picks[item][size] == 1) {
      fprintf(arquivo, "%d\n", item);
      item--;
      size -= weights[item];
    } else {
      item--;
    }
  }
}


x86 assembly (clang, -O0):
<print_picks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x21(%rbp)
jl     1143 <print_picks+0x33>
cmpl   $0x0,-0x8(%rbp)
setge  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1153 <print_picks+0x43>
jmp    11af <print_picks+0x9f>
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x8(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    11a1 <print_picks+0x91>
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe85(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    11aa <print_picks+0x9a>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    112a <print_picks+0x1a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_picks>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%eax
or     %esi,%eax
js     117b <print_picks+0x6b>
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdx,%r15
mov    %esi,%ebp
mov    %edi,%ebx
lea    0xecb(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%eax
mov    (%r12,%rax,8),%rax
mov    %ebp,%ecx
cmpl   $0x1,(%rax,%rcx,4)
jne    1170 <print_picks+0x60>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1030 <fprintf@plt>
movslq %ebx,%rax
add    $0xffffffff,%ebx
sub    -0x4(%r15,%rax,4),%ebp
test   %ebx,%ebx
jns    1177 <print_picks+0x67>
jmp    117b <print_picks+0x6b>
nopl   0x0(%rax)
add    $0xffffffff,%ebx
test   %ebx,%ebx
js     117b <print_picks+0x6b>
test   %ebp,%ebp
jns    1140 <print_picks+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
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 = %46, %5
%12 = load i32, i32* %6
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %7
%16 = icmp sge i32 %15, 0
br label %17
17: ; preds = %14, %11
%18 = phi i1 [ false, %11 ], [ %16, %14 ]
br i1 %18, label %19, label %47
19: ; preds = %17
%20 = load i32**, i32*** %9
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32*, i32** %20, i64 %22
%24 = load i32*, i32** %23
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %43
30: ; preds = %19
%31 = load i32*, i32** %10
%32 = load i32, i32* %6
%33 = call i32 @fprintf(i32* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %6
%35 = add nsw i32 %34, -1
store i32 %35, i32* %6
%36 = load i32*, i32** %8
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = load i32, i32* %7
%42 = sub nsw i32 %41, %40
store i32 %42, i32* %7
br label %46
43: ; preds = %19
%44 = load i32, i32* %6
%45 = add nsw i32 %44, -1
store i32 %45, i32* %6
br label %46
46: ; preds = %43, %30
br label %11
47: ; preds = %17
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 = or i32 %0, %1
%7 = icmp sgt i32 %6, -1
br i1 %7, label %8, label %33
8: ; preds = %5, %27
%9 = phi i32 [ %29, %27 ], [ %0, %5 ]
%10 = phi i32 [ %28, %27 ], [ %1, %5 ]
%11 = zext i32 %9 to i64
%12 = getelementptr inbounds i32*, i32** %3, i64 %11
%13 = load i32*, i32** %12
%14 = zext i32 %10 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 %25
18: ; preds = %8
%19 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%20 = add nsw i32 %9, -1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %2, i64 %21
%23 = load i32, i32* %22
%24 = sub nsw i32 %10, %23
br label %27
25: ; preds = %8
%26 = add nsw i32 %9, -1
br label %27
27: ; preds = %25, %18
%28 = phi i32 [ %24, %18 ], [ %10, %25 ]
%29 = phi i32 [ %20, %18 ], [ %26, %25 ]
%30 = icmp sgt i32 %29, -1
%31 = icmp sgt i32 %28, -1
%32 = select i1 %30, i1 %31, i1 false
br i1 %32, label %8, label %33
33: ; preds = %27, %5
ret void
}