#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 */
struct tm {
  int tm_isdst;
};

/* Variables and functions */
int /*<<< orphan*/ add_time(struct tm *, struct tm *);
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mktime(struct tm *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ *strptime(char *, char *, struct tm *);
int /*<<< orphan*/ subtract_time(struct tm *, struct tm *);
void make_time(struct tm *ts, int dston) {
  char buf[128];
  struct tm q;
  memset(&q, 0, sizeof(struct tm));
  ts->tm_isdst = dston;
  mktime(ts);
  strftime(buf, 128, "%z", ts);
  if (strptime(buf, "-%H%M", &q) != NULL)
    add_time(ts, &q);
  else if (strptime(buf, "+%H%M", &q) != NULL)
    subtract_time(ts, &q);
}


x86 assembly (clang, -O0):
<make_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x98(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
call   1050 <mktime@plt>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x80,%esi
lea    0xe52(%rip),%rdx
call   1070 <strftime@plt>
lea    -0x90(%rbp),%rdi
lea    0xe42(%rip),%rsi
lea    -0x98(%rbp),%rdx
call   1080 <strptime@plt>
cmp    $0x0,%rax
je     11ec <make_time+0x8c>
mov    -0x8(%rbp),%rdi
lea    -0x98(%rbp),%rsi
call   1030 <add_time@plt>
jmp    1225 <make_time+0xc5>
lea    -0x90(%rbp),%rdi
lea    0xe0f(%rip),%rsi
lea    -0x98(%rbp),%rdx
call   1080 <strptime@plt>
cmp    $0x0,%rax
je     1220 <make_time+0xc0>
mov    -0x8(%rbp),%rdi
lea    -0x98(%rbp),%rsi
call   1060 <subtract_time@plt>
jmp    1225 <make_time+0xc5>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_time>:
push   %rbp
push   %r14
push   %rbx
sub    $0x90,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %ebp,(%rbx)
mov    %rbx,%rdi
call   1050 <mktime@plt>
lea    0xe6b(%rip),%rdx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x80,%esi
mov    %rbx,%rcx
call   1070 <strftime@plt>
lea    0xe52(%rip),%rsi
mov    %rbp,%rdi
mov    %r14,%rdx
call   1080 <strptime@plt>
test   %rax,%rax
je     11d0 <make_time+0x70>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <add_time@plt>
jmp    11f8 <make_time+0x98>
lea    0xe32(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
call   1080 <strptime@plt>
test   %rax,%rax
je     11f8 <make_time+0x98>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <subtract_time@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [3 x i8] c"%z\00"
@.str.1 = [6 x i8] c"-%H%M\00"
@.str.2 = [6 x i8] c"+%H%M\00"
define void @make_time(%struct.tm* %0, i32 %1) {
%3 = alloca %struct.tm*
%4 = alloca i32
%5 = alloca [128 x i8]
%6 = alloca %struct.tm
store %struct.tm* %0, %struct.tm** %3
store i32 %1, i32* %4
%7 = call i32 @memset(%struct.tm* %6, i32 0, i32 4)
%8 = load i32, i32* %4
%9 = load %struct.tm*, %struct.tm** %3
%10 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 0
store i32 %8, i32* %10
%11 = load %struct.tm*, %struct.tm** %3
%12 = call i32 @mktime(%struct.tm* %11)
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%14 = load %struct.tm*, %struct.tm** %3
%15 = call i32 @strftime(i8* %13, i32 128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %14)
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%17 = call i32* @strptime(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %6)
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = load %struct.tm*, %struct.tm** %3
%21 = call i32 @add_time(%struct.tm* %20, %struct.tm* %6)
br label %30
22: ; preds = %2
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%24 = call i32* @strptime(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %6)
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load %struct.tm*, %struct.tm** %3
%28 = call i32 @subtract_time(%struct.tm* %27, %struct.tm* %6)
br label %29
29: ; preds = %26, %22
br label %30
30: ; preds = %29, %19
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [3 x i8] c"%z\00"
@.str.1 = [6 x i8] c"-%H%M\00"
@.str.2 = [6 x i8] c"+%H%M\00"
define void @make_time(%struct.tm* %0, i32 %1) {
%3 = alloca [128 x i8]
%4 = alloca %struct.tm
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.tm* %4 to i8*
%7 = call i32 @memset(%struct.tm* %4, i32 0, i32 4)
%8 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 0
store i32 %1, i32* %8
%9 = call i32 @mktime(%struct.tm* %0)
%10 = call i32 @strftime(i8* %5, i32 128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %0)
%11 = call i32* @strptime(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %4)
%12 = icmp eq i32* %11, null
br i1 %12, label %15, label %13
13: ; preds = %2
%14 = call i32 @add_time(%struct.tm* %0, %struct.tm* %4)
br label %20
15: ; preds = %2
%16 = call i32* @strptime(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %4)
%17 = icmp eq i32* %16, null
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 @subtract_time(%struct.tm* %0, %struct.tm* %4)
br label %20
20: ; preds = %15, %18, %13
ret void
}