#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;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ die(char *, char *);
scalar_t__ pit_arg_is_option(char **);
char *strchr(char *, char);
int /*<<< orphan*/ strcmp(char *, char *);
time_t pit_arg_time(char **arg, char *required) {
  int seconds = 0;
  if (required && (!*arg || pit_arg_is_option(arg))) {
    die("missing %s", required);
  } else if (!strcmp(*arg, "none")) {
    return -1;
  } else {
    char *colon = strchr(*arg, ':');
    if (colon == *arg) {
      seconds = atoi(++colon) * 60;
    } else if (colon) {
      *colon = '\0';
      seconds = atoi(*arg) * 3600 + atoi(++colon) * 60;
    } else {
      seconds = atoi(*arg) * 3600;
    }
  }
  if (!seconds) {
    die("invalid time format: %s", *arg);
  }
  return seconds;
}


x86 assembly (clang, -O0):
<pit_arg_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a8 <pit_arg_time+0x58>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1193 <pit_arg_time+0x43>
mov    -0x10(%rbp),%rdi
call   1050 <pit_arg_is_option@plt>
cmp    $0x0,%rax
je     11a8 <pit_arg_time+0x58>
mov    -0x18(%rbp),%rsi
lea    0xe62(%rip),%rdi
call   1060 <die@plt>
jmp    1280 <pit_arg_time+0x130>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe55(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11d0 <pit_arg_time+0x80>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a3 <pit_arg_time+0x153>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jne    1212 <pit_arg_time+0xc2>
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
mov    %rdi,-0x28(%rbp)
call   1070 <atoi@plt>
imul   $0x3c,%eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    1276 <pit_arg_time+0x126>
cmpq   $0x0,-0x28(%rbp)
je     125c <pit_arg_time+0x10c>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <atoi@plt>
imul   $0xe10,%eax,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
mov    %rdi,-0x28(%rbp)
call   1070 <atoi@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
imul   $0x3c,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
jmp    1271 <pit_arg_time+0x121>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <atoi@plt>
imul   $0xe10,%eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    1276 <pit_arg_time+0x126>
jmp    127b <pit_arg_time+0x12b>
jmp    1280 <pit_arg_time+0x130>
cmpl   $0x0,-0x1c(%rbp)
jne    129d <pit_arg_time+0x14d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd78(%rip),%rdi
call   1060 <die@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pit_arg_time>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
test   %rsi,%rsi
je     119d <pit_arg_time+0x4d>
mov    %rsi,%rbx
cmpq   $0x0,(%r15)
je     1175 <pit_arg_time+0x25>
mov    %r15,%rdi
call   1050 <pit_arg_is_option@plt>
test   %rax,%rax
je     119d <pit_arg_time+0x4d>
lea    0xe84(%rip),%rdi
mov    %rbx,%rsi
call   1060 <die@plt>
mov    (%r15),%r14
lea    0xe82(%rip),%rdi
mov    %r14,%rsi
call   1060 <die@plt>
xor    %eax,%eax
jmp    122a <pit_arg_time+0xda>
mov    (%r15),%r14
lea    0xe64(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11f8 <pit_arg_time+0xa8>
mov    %r14,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
cmp    %r14,%rax
je     11ff <pit_arg_time+0xaf>
mov    %rax,%rbx
test   %rax,%rax
je     1214 <pit_arg_time+0xc4>
movb   $0x0,(%rbx)
mov    (%r15),%r14
mov    %r14,%rdi
call   1070 <atoi@plt>
imul   $0xe10,%eax,%ebp
add    $0x1,%rbx
mov    %rbx,%rdi
call   1070 <atoi@plt>
imul   $0x3c,%eax,%eax
add    %ebp,%eax
test   %eax,%eax
jne    122a <pit_arg_time+0xda>
jmp    1187 <pit_arg_time+0x37>
mov    $0xffffffff,%eax
jmp    122a <pit_arg_time+0xda>
lea    0x1(%r14),%rdi
call   1070 <atoi@plt>
imul   $0x3c,%eax,%eax
test   %eax,%eax
jne    122a <pit_arg_time+0xda>
jmp    1187 <pit_arg_time+0x37>
mov    %r14,%rdi
call   1070 <atoi@plt>
imul   $0xe10,%eax,%eax
test   %eax,%eax
je     1187 <pit_arg_time+0x37>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"missing %s\00"
@.str.1 = [5 x i8] c"none\00"
@.str.2 = [24 x i8] c"invalid time format: %s\00"
define i32 @pit_arg_time(i8** %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i32 0, i32* %6
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %21
10: ; preds = %2
%11 = load i8**, i8*** %4
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i8**, i8*** %4
%16 = call i64 @pit_arg_is_option(i8** %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14, %10
%19 = load i8*, i8** %5
%20 = call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %62
21: ; preds = %14, %2
%22 = load i8**, i8*** %4
%23 = load i8*, i8** %22
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %21
store i32 -1, i32* %3
br label %71
27: ; preds = %21
%28 = load i8**, i8*** %4
%29 = load i8*, i8** %28
%30 = call i8* @strchr(i8* %29, i8 signext 58)
store i8* %30, i8** %7
%31 = load i8*, i8** %7
%32 = load i8**, i8*** %4
%33 = load i8*, i8** %32
%34 = icmp eq i8* %31, %33
br i1 %34, label %35, label %40
35: ; preds = %27
%36 = load i8*, i8** %7
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %7
%38 = call i32 @atoi(i8* %37)
%39 = mul nsw i32 %38, 60
store i32 %39, i32* %6
br label %60
40: ; preds = %27
%41 = load i8*, i8** %7
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %54
43: ; preds = %40
%44 = load i8*, i8** %7
store i8 0, i8* %44
%45 = load i8**, i8*** %4
%46 = load i8*, i8** %45
%47 = call i32 @atoi(i8* %46)
%48 = mul nsw i32 %47, 3600
%49 = load i8*, i8** %7
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %7
%51 = call i32 @atoi(i8* %50)
%52 = mul nsw i32 %51, 60
%53 = add nsw i32 %48, %52
store i32 %53, i32* %6
br label %59
54: ; preds = %40
%55 = load i8**, i8*** %4
%56 = load i8*, i8** %55
%57 = call i32 @atoi(i8* %56)
%58 = mul nsw i32 %57, 3600
store i32 %58, i32* %6
br label %59
59: ; preds = %54, %43
br label %60
60: ; preds = %59, %35
br label %61
61: ; preds = %60
br label %62
62: ; preds = %61, %18
%63 = load i32, i32* %6
%64 = icmp ne i32 %63, 0
br i1 %64, label %69, label %65
65: ; preds = %62
%66 = load i8**, i8*** %4
%67 = load i8*, i8** %66
%68 = call i32 @die(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %67)
br label %69
69: ; preds = %65, %62
%70 = load i32, i32* %6
store i32 %70, i32* %3
br label %71
71: ; preds = %69, %26
%72 = load i32, i32* %3
ret i32 %72
}

LLVM IR (-O2):
@.str = [11 x i8] c"missing %s\00"
@.str.1 = [5 x i8] c"none\00"
@.str.2 = [24 x i8] c"invalid time format: %s\00"
define i32 @pit_arg_time(i8** %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %13, label %4
4: ; preds = %2
%5 = load i8*, i8** %0
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i64 @pit_arg_is_option(i8** %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %4, %7
%11 = tail call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %1)
%12 = load i8*, i8** %0
br label %41
13: ; preds = %7, %2
%14 = load i8*, i8** %0
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %14, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %44, label %17
17: ; preds = %13
%18 = tail call i8* @strchr(i8* dereferenceable(1) %14, i8 signext 58)
%19 = icmp eq i8* %18, %14
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = getelementptr inbounds i8, i8* %14, i64 1
%22 = tail call i32 @atoi(i8* %21)
%23 = mul nsw i32 %22, 60
br label %37
24: ; preds = %17
%25 = icmp eq i8* %18, null
br i1 %25, label %34, label %26
26: ; preds = %24
store i8 0, i8* %18
%27 = load i8*, i8** %0
%28 = tail call i32 @atoi(i8* %27)
%29 = mul nsw i32 %28, 3600
%30 = getelementptr inbounds i8, i8* %18, i64 1
%31 = tail call i32 @atoi(i8* %30)
%32 = mul nsw i32 %31, 60
%33 = add nsw i32 %32, %29
br label %37
34: ; preds = %24
%35 = tail call i32 @atoi(i8* %14)
%36 = mul nsw i32 %35, 3600
br label %37
37: ; preds = %20, %34, %26
%38 = phi i8* [ %14, %20 ], [ %27, %26 ], [ %14, %34 ]
%39 = phi i32 [ %23, %20 ], [ %33, %26 ], [ %36, %34 ]
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %10, %37
%42 = phi i8* [ %12, %10 ], [ %38, %37 ]
%43 = tail call i32 @die(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %37, %41, %13
%45 = phi i32 [ -1, %13 ], [ 0, %41 ], [ %39, %37 ]
ret i32 %45
}