#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 time_t;
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ res;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ localtime_r(int *, struct tm *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strftime(char *, int, char *, struct tm *);
int main(int argc, char *argv[]) {
  time_t t;
  struct tm lt;
  char res[32];
  t = 1452849871;
  t = (time_t)atoi(argv[1]);
  localtime_r(&t, &lt);
  if (strftime(res, sizeof(res), "%H", &lt) == 0) {
    printf("error\n");
    return 1;
  }
  printf("%u -> %d\n", t, atoi(res));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5698bacf,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <localtime_r@plt>
lea    -0x40(%rbp),%rdi
mov    $0x20,%esi
lea    0xe76(%rip),%rdx
lea    -0x18(%rbp),%rcx
call   1050 <strftime@plt>
cmp    $0x0,%rax
jne    11b7 <main+0x77>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d9 <main+0x99>
mov    -0x14(%rbp),%eax
mov    %eax,-0x44(%rbp)
lea    -0x40(%rbp),%rdi
call   1060 <atoi@plt>
mov    -0x44(%rbp),%esi
mov    %eax,%edx
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <localtime_r@plt>
lea    0xe84(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x20,%esi
mov    %rbx,%rcx
call   1060 <strftime@plt>
test   %rax,%rax
je     11b7 <main+0x67>
mov    0x4(%rsp),%ebp
lea    0x10(%rsp),%rdi
call   1070 <atoi@plt>
lea    0xe5b(%rip),%rdi
xor    %ebx,%ebx
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c8 <main+0x78>
lea    0xe4f(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [3 x i8] c"%H\00"
@.str.1 = [7 x i8] c"error\0A\00"
@.str.2 = [10 x i8] c"%u -> %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.tm
%8 = alloca [32 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1452849871, i32* %6
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %6
%13 = call i32 @localtime_r(i32* %6, %struct.tm* %7)
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%15 = call i64 @strftime(i8* %14, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %7)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %24
19: ; preds = %2
%20 = load i32, i32* %6
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%22 = call i32 @atoi(i8* %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %22)
br label %24
24: ; preds = %19, %17
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [3 x i8] c"%H\00"
@.str.2 = [10 x i8] c"%u -> %d\0A\00"
@str = [6 x i8] c"error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.tm
%5 = alloca [32 x i8]
%6 = bitcast i32* %3 to i8*
%7 = bitcast %struct.tm* %4 to i8*
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
store i32 %11, i32* %3
%12 = call i32 @localtime_r(i32* %3, %struct.tm* %4)
%13 = call i64 @strftime(i8* %8, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %21
17: ; preds = %2
%18 = load i32, i32* %3
%19 = call i32 @atoi(i8* %8)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19)
br label %21
21: ; preds = %17, %15
%22 = phi i32 [ 1, %15 ], [ 0, %17 ]
ret i32 %22
}