#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*/ time_t;
struct tm {
  int tm_hour;
  int tm_min;
  scalar_t__ tm_sec;
};

/* Variables and functions */
char *asctime(struct tm *);
scalar_t__ db_query(int /*<<< orphan*/ *, int /*<<< orphan*/ *, char *);
struct tm *localtime(int /*<<< orphan*/ *);
int mktime(struct tm *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void setHorarios(void) {
  printf("Iniciado gravação de horas.\n");
  int i5;
  time_t nowTime;
  struct tm *cur;
  char sql[1000];
  nowTime = time(NULL);
  cur = localtime(&nowTime);
  cur->tm_sec = 0;
  for (i5 = 0; i5 < 10; i5++) {
    if (i5 % 2) {
      cur->tm_hour = 21;
      cur->tm_min = 00;
    } else {
      cur->tm_hour = 19;
      cur->tm_min = 00;
    }
    sprintf(sql,
            "UPDATE horario SET hora_inicial = strftime('%%H:%%M', %d, "
            "'unixepoch') WHERE codhorario = %d;",
            mktime(cur), i5 + 1);
    printf("%d, %d - %s\n", i5 + 1, 0 == db_query(NULL, NULL, sql),
           asctime(cur));
  }
}


x86 assembly (clang, -O0):
<setHorarios>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x8(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x0,0x8(%rax)
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    129d <setHorarios+0x12d>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11ed <setHorarios+0x7d>
mov    -0x10(%rbp),%rax
movl   $0x15,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,0x4(%rax)
jmp    1202 <setHorarios+0x92>
mov    -0x10(%rbp),%rax
movl   $0x13,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,0x4(%rax)
lea    -0x400(%rbp),%rax
mov    %rax,-0x410(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <mktime@plt>
mov    -0x410(%rbp),%rdi
mov    %eax,%edx
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
lea    0xdf0(%rip),%rsi
call   1090 <sprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x408(%rbp)
lea    -0x400(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%esi
mov    %rsi,%rdi
call   1080 <db_query@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x404(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <asctime@plt>
mov    -0x408(%rbp),%esi
mov    -0x404(%rbp),%edx
mov    %rax,%rcx
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11b5 <setHorarios+0x45>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setHorarios>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f8,%rsp
lea    0xed3(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%r14
movq   $0x0,0x8(%rax)
mov    $0x1,%ebx
lea    0xe37(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xe89(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x1(%rbx),%eax
and    $0x1,%eax
add    %eax,%eax
add    $0x13,%eax
mov    %eax,(%r14)
movl   $0x0,0x4(%r14)
mov    %r14,%rdi
call   1080 <mktime@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %eax,%edx
mov    %ebx,%ecx
call   10a0 <sprintf@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %r12,%rdx
call   1090 <db_query@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
mov    %r14,%rdi
call   1050 <asctime@plt>
mov    %r13,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebx
cmp    $0xb,%ebx
jne    11e0 <setHorarios+0x60>
add    $0x3f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i64 }
@.str = [31 x i8] c"Iniciado grava\C3\A7\C3\A3o de horas.\0A\00"
@.str.1 = [94 x i8] c"UPDATE horario SET hora_inicial = strftime('%%H:%%M', %d, 'unixepoch') WHERE codhorario = %d;\00"
@.str.2 = [13 x i8] c"%d, %d - %s\0A\00"
define void @setHorarios() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = alloca [1000 x i8]
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @time(i32* null)
store i32 %6, i32* %2
%7 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %7, %struct.tm** %3
%8 = load %struct.tm*, %struct.tm** %3
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 2
store i64 0, i64* %9
store i32 0, i32* %1
br label %10
10: ; preds = %43, %0
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %46
13: ; preds = %10
%14 = load i32, i32* %1
%15 = srem i32 %14, 2
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load %struct.tm*, %struct.tm** %3
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 0
store i32 21, i32* %19
%20 = load %struct.tm*, %struct.tm** %3
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 1
store i32 0, i32* %21
br label %27
22: ; preds = %13
%23 = load %struct.tm*, %struct.tm** %3
%24 = getelementptr inbounds %struct.tm, %struct.tm* %23, i32 0, i32 0
store i32 19, i32* %24
%25 = load %struct.tm*, %struct.tm** %3
%26 = getelementptr inbounds %struct.tm, %struct.tm* %25, i32 0, i32 1
store i32 0, i32* %26
br label %27
27: ; preds = %22, %17
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%29 = load %struct.tm*, %struct.tm** %3
%30 = call i32 @mktime(%struct.tm* %29)
%31 = load i32, i32* %1
%32 = add nsw i32 %31, 1
%33 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.1, i64 0, i64 0), i32 %30, i32 %32)
%34 = load i32, i32* %1
%35 = add nsw i32 %34, 1
%36 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%37 = call i64 @db_query(i32* null, i32* null, i8* %36)
%38 = icmp eq i64 0, %37
%39 = zext i1 %38 to i32
%40 = load %struct.tm*, %struct.tm** %3
%41 = call i8* @asctime(%struct.tm* %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32 %39, i8* %41)
br label %43
43: ; preds = %27
%44 = load i32, i32* %1
%45 = add nsw i32 %44, 1
store i32 %45, i32* %1
br label %10
46: ; preds = %10
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i64 }
@.str.1 = [94 x i8] c"UPDATE horario SET hora_inicial = strftime('%%H:%%M', %d, 'unixepoch') WHERE codhorario = %d;\00"
@.str.2 = [13 x i8] c"%d, %d - %s\0A\00"
@str = [30 x i8] c"Iniciado grava\C3\A7\C3\A3o de horas.\00"
define void @setHorarios() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%6 = tail call i32 @time(i32* null)
store i32 %6, i32* %1
%7 = call %struct.tm* @localtime(i32* %1)
%8 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 2
store i64 0, i64* %8
%9 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 0
%10 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 1
br label %11
11: ; preds = %0, %11
%12 = phi i32 [ 0, %0 ], [ %17, %11 ]
%13 = and i32 %12, 1
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i32 19, i32 21
store i32 %15, i32* %9
store i32 0, i32* %10
%16 = call i32 @mktime(%struct.tm* %7)
%17 = add nuw nsw i32 %12, 1
%18 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([94 x i8], [94 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %17)
%19 = call i64 @db_query(i32* null, i32* null, i8* %5)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
%22 = call i8* @asctime(%struct.tm* %7)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %21, i8* %22)
%24 = icmp eq i32 %17, 10
br i1 %24, label %25, label %11
25: ; preds = %11
ret void
}