#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 */
struct mapred_token_store {
  int dummy;
};
struct mapred_scheduler {
  int dummy;
};

/* Variables and functions */
int errno;
struct mapred_token_store const *
mapred_process_reduce_works(struct mapred_scheduler *);
int mapred_schedule_map_works(struct mapred_scheduler *, char const *, size_t);
const struct mapred_token_store *
mapred_run_work_scheduler(struct mapred_scheduler *scheduler, const char *data,
                          size_t size) {
  int err;
  err = mapred_schedule_map_works(scheduler, data, size);
  if (err) {
    errno = -err;
    return NULL;
  }
  return mapred_process_reduce_works(scheduler);
}


x86 assembly (clang, -O0):
<mapred_run_work_scheduler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <mapred_schedule_map_works@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     116d <mapred_run_work_scheduler+0x4d>
xor    %ecx,%ecx
sub    -0x24(%rbp),%ecx
mov    0x2e82(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    117a <mapred_run_work_scheduler+0x5a>
mov    -0x10(%rbp),%rdi
call   1030 <mapred_process_reduce_works@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mapred_run_work_scheduler>:
push   %rbx
mov    %rdi,%rbx
call   1040 <mapred_schedule_map_works@plt>
test   %eax,%eax
je     113c <mapred_run_work_scheduler+0x1c>
neg    %eax
mov    0x2eaa(%rip),%rcx
mov    %eax,(%rcx)
xor    %eax,%eax
pop    %rbx
ret
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <mapred_process_reduce_works@plt>

LLVM IR (-O0):
%struct.mapred_token_store = type { i32 }
%struct.mapred_scheduler = type { i32 }
@errno = global i32 0
define %struct.mapred_token_store* @mapred_run_work_scheduler(%struct.mapred_scheduler* %0, i8* %1, i64 %2) {
%4 = alloca %struct.mapred_token_store*
%5 = alloca %struct.mapred_scheduler*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store %struct.mapred_scheduler* %0, %struct.mapred_scheduler** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%9 = load %struct.mapred_scheduler*, %struct.mapred_scheduler** %5
%10 = load i8*, i8** %6
%11 = load i64, i64* %7
%12 = call i32 @mapred_schedule_map_works(%struct.mapred_scheduler* %9, i8* %10, i64 %11)
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = load i32, i32* %8
%17 = sub nsw i32 0, %16
store i32 %17, i32* @errno
store %struct.mapred_token_store* null, %struct.mapred_token_store** %4
br label %21
18: ; preds = %3
%19 = load %struct.mapred_scheduler*, %struct.mapred_scheduler** %5
%20 = call %struct.mapred_token_store* @mapred_process_reduce_works(%struct.mapred_scheduler* %19)
store %struct.mapred_token_store* %20, %struct.mapred_token_store** %4
br label %21
21: ; preds = %18, %15
%22 = load %struct.mapred_token_store*, %struct.mapred_token_store** %4
ret %struct.mapred_token_store* %22
}

LLVM IR (-O2):
%struct.mapred_token_store = type { i32 }
%struct.mapred_scheduler = type { i32 }
@errno = global i32 0
define %struct.mapred_token_store* @mapred_run_work_scheduler(%struct.mapred_scheduler* %0, i8* %1, i64 %2) {
%4 = tail call i32 @mapred_schedule_map_works(%struct.mapred_scheduler* %0, i8* %1, i64 %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = sub nsw i32 0, %4
store i32 %7, i32* @errno
br label %10
8: ; preds = %3
%9 = tail call %struct.mapred_token_store* @mapred_process_reduce_works(%struct.mapred_scheduler* %0)
br label %10
10: ; preds = %8, %6
%11 = phi %struct.mapred_token_store* [ null, %6 ], [ %9, %8 ]
ret %struct.mapred_token_store* %11
}