#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*/ logMessage(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *, char *,
                           char *);
char *strtok(char *, char *);
scalar_t__ system(char *);
int configurar_fecha(char *fecha_hora) {
  char *anho;
  char *mes;
  char *dia;
  char *hora;
  char *minutos;
  char *segundos;
  char formato_fecha[40];
  anho = strtok(fecha_hora, "-");
  logMessage("anho: %s", anho);
  mes = strtok(NULL, "-");
  logMessage("mes: %s", mes);
  dia = strtok(NULL, "-");
  logMessage("dia: %s", dia);
  hora = strtok(NULL, "-");
  logMessage("hora: %s", hora);
  minutos = strtok(NULL, "-");
  logMessage("minutos: %s", minutos);
  segundos = strtok(NULL, "-");
  logMessage("segundos: %s", segundos);
  sprintf(formato_fecha, "date --set \"%s-%s-%s %s:%s\"", anho, mes, dia, hora,
          minutos);
  logMessage(formato_fecha);
  if (system(formato_fecha) != 0) {
    logMessage("No se pudo cambiar la hora");
    return -1;
  }
  logMessage("Se cambio la hora exitosamente");
  return 0;
}


x86 assembly (clang, -O0):
<configurar_fecha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <logMessage@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe80(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <logMessage@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe5a(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <logMessage@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe34(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <logMessage@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe0e(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <logMessage@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xde8(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1030 <logMessage@plt>
lea    -0x70(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
mov    -0x38(%rbp),%rax
lea    0xdeb(%rip),%rsi
mov    %rax,(%rsp)
call   1060 <sprintf@plt>
lea    -0x70(%rbp),%rdi
mov    $0x0,%al
call   1030 <logMessage@plt>
lea    -0x70(%rbp),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
je     1293 <configurar_fecha+0x153>
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <logMessage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a8 <configurar_fecha+0x168>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1030 <logMessage@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<configurar_fecha>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xeab(%rip),%r12
mov    %r12,%rsi
call   1050 <strtok@plt>
mov    %rax,%r14
lea    0xe9b(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <logMessage@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1050 <strtok@plt>
mov    %rax,%r15
lea    0xe86(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <logMessage@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1050 <strtok@plt>
mov    %rax,%r13
lea    0xe70(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <logMessage@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1050 <strtok@plt>
mov    %rax,%rbx
lea    0xe5a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <logMessage@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1050 <strtok@plt>
mov    %rax,%rbp
lea    0xe45(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <logMessage@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1050 <strtok@plt>
lea    0xe36(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <logMessage@plt>
mov    %rbp,(%rsp)
lea    0xe2e(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r13,%r8
mov    %rbx,%r9
call   1060 <sprintf@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <logMessage@plt>
mov    %rbp,%rdi
call   1040 <system@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
lea    0xe2b(%rip),%rax
lea    0xe09(%rip),%rdi
cmove  %rax,%rdi
neg    %ebx
xor    %eax,%eax
call   1030 <logMessage@plt>
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [9 x i8] c"anho: %s\00"
@.str.2 = [8 x i8] c"mes: %s\00"
@.str.3 = [8 x i8] c"dia: %s\00"
@.str.4 = [9 x i8] c"hora: %s\00"
@.str.5 = [12 x i8] c"minutos: %s\00"
@.str.6 = [13 x i8] c"segundos: %s\00"
@.str.7 = [28 x i8] c"date --set \22%s-%s-%s %s:%s\22\00"
@.str.8 = [27 x i8] c"No se pudo cambiar la hora\00"
@.str.9 = [31 x i8] c"Se cambio la hora exitosamente\00"
define i32 @configurar_fecha(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [40 x i8]
store i8* %0, i8** %3
%11 = load i8*, i8** %3
%12 = call i8* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = call i32 (i8*, ...) @logMessage(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = call i32 (i8*, ...) @logMessage(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = call i32 (i8*, ...) @logMessage(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %21, i8** %7
%22 = load i8*, i8** %7
%23 = call i32 (i8*, ...) @logMessage(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %22)
%24 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %24, i8** %8
%25 = load i8*, i8** %8
%26 = call i32 (i8*, ...) @logMessage(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %25)
%27 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %27, i8** %9
%28 = load i8*, i8** %9
%29 = call i32 (i8*, ...) @logMessage(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [40 x i8], [40 x i8]* %10, i64 0, i64 0
%31 = load i8*, i8** %4
%32 = load i8*, i8** %5
%33 = load i8*, i8** %6
%34 = load i8*, i8** %7
%35 = load i8*, i8** %8
%36 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i8* %31, i8* %32, i8* %33, i8* %34, i8* %35)
%37 = getelementptr inbounds [40 x i8], [40 x i8]* %10, i64 0, i64 0
%38 = call i32 (i8*, ...) @logMessage(i8* %37)
%39 = getelementptr inbounds [40 x i8], [40 x i8]* %10, i64 0, i64 0
%40 = call i64 @system(i8* %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %1
%43 = call i32 (i8*, ...) @logMessage(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %2
br label %46
44: ; preds = %1
%45 = call i32 (i8*, ...) @logMessage(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %2
br label %46
46: ; preds = %44, %42
%47 = load i32, i32* %2
ret i32 %47
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@.str.1 = [9 x i8] c"anho: %s\00"
@.str.2 = [8 x i8] c"mes: %s\00"
@.str.3 = [8 x i8] c"dia: %s\00"
@.str.4 = [9 x i8] c"hora: %s\00"
@.str.5 = [12 x i8] c"minutos: %s\00"
@.str.6 = [13 x i8] c"segundos: %s\00"
@.str.7 = [28 x i8] c"date --set \22%s-%s-%s %s:%s\22\00"
@.str.8 = [27 x i8] c"No se pudo cambiar la hora\00"
@.str.9 = [31 x i8] c"Se cambio la hora exitosamente\00"
define i32 @configurar_fecha(i8* %0) {
%2 = alloca [40 x i8]
%3 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%4 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @logMessage(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @logMessage(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%8 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @logMessage(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%10 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @logMessage(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%12 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @logMessage(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %12)
%14 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @logMessage(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %14)
%16 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i8* %4, i8* %6, i8* %8, i8* %10, i8* %12)
%17 = call i32 (i8*, ...) @logMessage(i8* %3)
%18 = call i64 @system(i8* %3)
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0)
%21 = xor i1 %19, true
%22 = sext i1 %21 to i32
%23 = call i32 (i8*, ...) @logMessage(i8* %20)
ret i32 %22
}