#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 */
scalar_t__ db_query(int /*<<< orphan*/ *, int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
int /*<<< orphan*/ stderr;
int horaAssociarDisciplina(int codHorario, int codDisciplina) {
  char query[150];
  if (codHorario == 0) {
    fprintf(stderr, "Horário não informado.");
    return 1;
  }
  if (codDisciplina == 0)
    sprintf(query, "UPDATE horario SET coddisc = NULL where codhorario = %d;",
            codHorario);
  else
    sprintf(query, "UPDATE horario SET coddisc = %d where codhorario = %d;",
            codDisciplina, codHorario);
  if (db_query(NULL, NULL, query) == 0)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<horaAssociarDisciplina>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    116c <horaAssociarDisciplina+0x3c>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11de <horaAssociarDisciplina+0xae>
cmpl   $0x0,-0xc(%rbp)
jne    1193 <horaAssociarDisciplina+0x63>
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    11ae <horaAssociarDisciplina+0x7e>
lea    -0xb0(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xeab(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0xb0(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%esi
mov    %rsi,%rdi
call   1040 <db_query@plt>
cmp    $0x0,%rax
jne    11d7 <horaAssociarDisciplina+0xa7>
movl   $0x1,-0x4(%rbp)
jmp    11de <horaAssociarDisciplina+0xae>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<horaAssociarDisciplina>:
sub    $0x98,%rsp
test   %edi,%edi
je     1156 <horaAssociarDisciplina+0x26>
mov    %esi,%edx
mov    %edi,%ecx
test   %esi,%esi
je     1178 <horaAssociarDisciplina+0x48>
lea    0xf08(%rip),%rsi
mov    %rsp,%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    118b <horaAssociarDisciplina+0x5b>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
lea    0xe9a(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%eax
add    $0x98,%rsp
ret
lea    0xe9a(%rip),%rsi
mov    %rsp,%rdi
mov    %ecx,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rsp,%rdx
xor    %edi,%edi
xor    %esi,%esi
call   1040 <db_query@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
add    $0x98,%rsp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"Hor\C3\A1rio n\C3\A3o informado.\00"
@.str.1 = [57 x i8] c"UPDATE horario SET coddisc = NULL where codhorario = %d;\00"
@.str.2 = [55 x i8] c"UPDATE horario SET coddisc = %d where codhorario = %d;\00"
define i32 @horaAssociarDisciplina(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [150 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %30
12: ; preds = %2
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = getelementptr inbounds [150 x i8], [150 x i8]* %6, i64 0, i64 0
%17 = load i32, i32* %4
%18 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %24
19: ; preds = %12
%20 = getelementptr inbounds [150 x i8], [150 x i8]* %6, i64 0, i64 0
%21 = load i32, i32* %5
%22 = load i32, i32* %4
%23 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i32 %21, i32 %22)
br label %24
24: ; preds = %19, %15
%25 = getelementptr inbounds [150 x i8], [150 x i8]* %6, i64 0, i64 0
%26 = call i64 @db_query(i32* null, i32* null, i8* %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
store i32 1, i32* %3
br label %30
29: ; preds = %24
store i32 0, i32* %3
br label %30
30: ; preds = %29, %28, %9
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Hor\C3\A1rio n\C3\A3o informado.\00"
@.str.1 = [57 x i8] c"UPDATE horario SET coddisc = NULL where codhorario = %d;\00"
@.str.2 = [55 x i8] c"UPDATE horario SET coddisc = %d where codhorario = %d;\00"
define i32 @horaAssociarDisciplina(i32 %0, i32 %1) {
%3 = alloca [150 x i8]
%4 = getelementptr inbounds [150 x i8], [150 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %19
9: ; preds = %2
%10 = icmp eq i32 %1, 0
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %15
13: ; preds = %9
%14 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i32 %1, i32 %0)
br label %15
15: ; preds = %13, %11
%16 = call i64 @db_query(i32* null, i32* null, i8* %4)
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %15, %6
%20 = phi i32 [ 1, %6 ], [ %18, %15 ]
ret i32 %20
}