#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*/ free(char *);
char *get_habit(char *);
int get_ngates(char *);
int get_score(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ tee_habit(int /*<<< orphan*/ *, int, char *, char *, int,
                             int);
void update_reward(FILE *f, int id, char *line, char *reward) {
  char *habit = get_habit(line);
  int score = get_score(line);
  int ngates = get_ngates(line);
  printf("Reward for habit %d updated:\n", id);
  tee_habit(f, id, habit, reward, score, ngates);
  free(habit);
}


x86 assembly (clang, -O0):
<update_reward>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <get_habit@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <get_score@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <get_ngates@plt>
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe5a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
call   1080 <tee_habit@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_reward>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r15
mov    %rdx,%rdi
call   1070 <get_habit@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1060 <get_score@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
call   1040 <get_ngates@plt>
mov    %eax,%ebx
lea    0xe63(%rip),%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r12,%rdx
mov    %r14,%rcx
mov    %r13d,%r8d
mov    %ebx,%r9d
call   1080 <tee_habit@plt>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Reward for habit %d updated:\0A\00"
define void @update_reward(i32* %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%12 = load i8*, i8** %7
%13 = call i8* @get_habit(i8* %12)
store i8* %13, i8** %9
%14 = load i8*, i8** %7
%15 = call i32 @get_score(i8* %14)
store i32 %15, i32* %10
%16 = load i8*, i8** %7
%17 = call i32 @get_ngates(i8* %16)
store i32 %17, i32* %11
%18 = load i32, i32* %6
%19 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load i32*, i32** %5
%21 = load i32, i32* %6
%22 = load i8*, i8** %9
%23 = load i8*, i8** %8
%24 = load i32, i32* %10
%25 = load i32, i32* %11
%26 = call i32 @tee_habit(i32* %20, i32 %21, i8* %22, i8* %23, i32 %24, i32 %25)
%27 = load i8*, i8** %9
%28 = call i32 @free(i8* %27)
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"Reward for habit %d updated:\0A\00"
define void @update_reward(i32* %0, i32 %1, i8* %2, i8* %3) {
%5 = tail call i8* @get_habit(i8* %2)
%6 = tail call i32 @get_score(i8* %2)
%7 = tail call i32 @get_ngates(i8* %2)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %1)
%9 = tail call i32 @tee_habit(i32* %0, i32 %1, i8* %5, i8* %3, i32 %6, i32 %7)
%10 = tail call i32 @free(i8* %5)
ret void
}