#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);
scalar_t__ picosat_corelit(int);
int picosat_variables();
void write_core_variables(FILE *file) {
  int i, max_idx = picosat_variables();
  for (i = 1; i <= max_idx; i++)
    if (picosat_corelit(i))
      fprintf(file, "%d\n", i);
}


x86 assembly (clang, -O0):
<write_core_variables>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <picosat_variables@plt>
mov    %eax,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1191 <write_core_variables+0x61>
mov    -0xc(%rbp),%edi
call   1040 <picosat_corelit@plt>
cmp    $0x0,%rax
je     117e <write_core_variables+0x4e>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe87(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1183 <write_core_variables+0x53>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <write_core_variables+0x1d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_core_variables>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1050 <picosat_variables@plt>
test   %eax,%eax
jle    118e <write_core_variables+0x5e>
mov    %eax,%r15d
neg    %r15d
mov    $0x1,%ebx
lea    0xea8(%rip),%r12
jmp    1173 <write_core_variables+0x43>
nopw   0x0(%rax,%rax,1)
lea    (%r15,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
je     118e <write_core_variables+0x5e>
mov    %ebx,%edi
call   1040 <picosat_corelit@plt>
test   %rax,%rax
je     1160 <write_core_variables+0x30>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1030 <fprintf@plt>
jmp    1160 <write_core_variables+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define void @write_core_variables(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
%5 = call i32 (...) @picosat_variables()
store i32 %5, i32* %4
store i32 1, i32* %3
br label %6
6: ; preds = %19, %1
%7 = load i32, i32* %3
%8 = load i32, i32* %4
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %22
10: ; preds = %6
%11 = load i32, i32* %3
%12 = call i64 @picosat_corelit(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32*, i32** %2
%16 = load i32, i32* %3
%17 = call i32 @fprintf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %14, %10
br label %19
19: ; preds = %18
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %6
22: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @write_core_variables(i32* nocapture %0) {
%2 = tail call i32 (...) @picosat_variables()
%3 = icmp slt i32 %2, 1
br i1 %3, label %13, label %4
4: ; preds = %1, %10
%5 = phi i32 [ %11, %10 ], [ 1, %1 ]
%6 = tail call i64 @picosat_corelit(i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %10
10: ; preds = %4, %8
%11 = add nuw i32 %5, 1
%12 = icmp eq i32 %5, %2
br i1 %12, label %13, label %4
13: ; preds = %10, %1
ret void
}