#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 /*<<< orphan*/ printf(char *);
int c_worker_func(void *user_context,
                  int (*cythonCallback)(int percentage, void *user_context)) {
  int response = 1;
  int errNum = 0;
  int i;
  for (i = 0; i < 100; i++) {
    if (cythonCallback(i + 1, user_context)) {
      printf("non-zero exit status from callback, exiting...\n");
      errNum++;
      break;
    }
    long long int i;
    long long int j;
    for (i = 0; i < 10000000; i++) {
      j += i * i + i;
    }
  }
  if (errNum == 0)
    response = 0;
  return response;
}


x86 assembly (clang, -O0):
<c_worker_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x64,-0x1c(%rbp)
jge    11c1 <c_worker_func+0xb1>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%rsi
call   *%rax
cmp    $0x0,%eax
je     1172 <c_worker_func+0x62>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c1 <c_worker_func+0xb1>
movq   $0x0,-0x28(%rbp)
cmpq   $0x989680,-0x28(%rbp)
jge    11ae <c_worker_func+0x9e>
mov    -0x28(%rbp),%rax
imul   -0x28(%rbp),%rax
add    -0x28(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    117a <c_worker_func+0x6a>
jmp    11b3 <c_worker_func+0xa3>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1135 <c_worker_func+0x25>
cmpl   $0x0,-0x18(%rbp)
jne    11d2 <c_worker_func+0xc2>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_worker_func>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x1,%edi
mov    %r15,%rsi
call   *%r14
mov    $0x1,%bl
test   %eax,%eax
jne    115f <c_worker_func+0x4f>
xor    %ebx,%ebx
mov    $0x2,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0xffffff9d,%ebx
je     1179 <c_worker_func+0x69>
mov    %ebp,%edi
mov    %r15,%rsi
call   *%r14
add    $0xffffffff,%ebx
add    $0x1,%ebp
test   %eax,%eax
je     1140 <c_worker_func+0x30>
not    %ebx
cmp    $0x63,%ebx
setb   %bl
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
movzbl %bl,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
neg    %ebx
cmp    $0x63,%ebx
setb   %bl
jmp    116b <c_worker_func+0x5b>

LLVM IR (-O0):
@.str = [48 x i8] c"non-zero exit status from callback, exiting...\0A\00"
define i32 @c_worker_func(i8* %0, i32 (i32, i8*)* %1) {
%3 = alloca i8*
%4 = alloca i32 (i32, i8*)*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
store i8* %0, i8** %3
store i32 (i32, i8*)* %1, i32 (i32, i8*)** %4
store i32 1, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %10
10: ; preds = %40, %2
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 100
br i1 %12, label %13, label %43
13: ; preds = %10
%14 = load i32 (i32, i8*)*, i32 (i32, i8*)** %4
%15 = load i32, i32* %7
%16 = add nsw i32 %15, 1
%17 = load i8*, i8** %3
%18 = call i32 %14(i32 %16, i8* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %13
%21 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %43
24: ; preds = %13
store i64 0, i64* %8
br label %25
25: ; preds = %36, %24
%26 = load i64, i64* %8
%27 = icmp slt i64 %26, 10000000
br i1 %27, label %28, label %39
28: ; preds = %25
%29 = load i64, i64* %8
%30 = load i64, i64* %8
%31 = mul nsw i64 %29, %30
%32 = load i64, i64* %8
%33 = add nsw i64 %31, %32
%34 = load i64, i64* %9
%35 = add nsw i64 %34, %33
store i64 %35, i64* %9
br label %36
36: ; preds = %28
%37 = load i64, i64* %8
%38 = add nsw i64 %37, 1
store i64 %38, i64* %8
br label %25
39: ; preds = %25
br label %40
40: ; preds = %39
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %10
43: ; preds = %20, %10
%44 = load i32, i32* %6
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %43
store i32 0, i32* %5
br label %47
47: ; preds = %46, %43
%48 = load i32, i32* %5
ret i32 %48
}

LLVM IR (-O2):
@str = [47 x i8] c"non-zero exit status from callback, exiting...\00"
define i32 @c_worker_func(i8* %0, i32 (i32, i8*)* nocapture %1) {
%3 = tail call i32 %1(i32 1, i8* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %9, label %15
5: ; preds = %9
%6 = add nuw nsw i32 %10, 1
%7 = tail call i32 %1(i32 %6, i8* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2, %5
%10 = phi i32 [ %6, %5 ], [ 1, %2 ]
%11 = phi i32 [ %10, %5 ], [ 0, %2 ]
%12 = icmp eq i32 %10, 100
br i1 %12, label %18, label %5
13: ; preds = %5
%14 = icmp ult i32 %11, 99
br label %15
15: ; preds = %13, %2
%16 = phi i1 [ true, %2 ], [ %14, %13 ]
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %20
18: ; preds = %9
%19 = icmp ult i32 %11, 99
br label %20
20: ; preds = %18, %15
%21 = phi i1 [ %16, %15 ], [ %19, %18 ]
%22 = zext i1 %21 to i32
ret i32 %22
}