#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*/ fprintf(int /*<<< orphan*/, char *, char const *);
int sscanf(char const *, char const *, int *, char *);
int /*<<< orphan*/ stderr;
void convertInt(const char *in, int *out) {
  const char format[] = "%i%c";
  char unit;
  int backup = *out;
  int status = sscanf(in, format, out, &unit);
  if (status < 1 || status > 2) {
    fprintf(stderr, "Conversion of '%s' failed.\n", in);
    *out = backup;
  } else if (status == 2) {
    switch (unit) {
    case 'H':
    case 'h':
      *out *= 3600;
      break;
    case 'M':
    case 'm':
      *out *= 60;
      break;
    case 'S':
    case 's':
    default:
      break;
    }
  }
}


x86 assembly (clang, -O0):
<convertInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeca(%rip),%eax
mov    %eax,-0x15(%rbp)
mov    0xec5(%rip),%al
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x15(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    -0x16(%rbp),%rcx
call   1040 <sscanf@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jl     1177 <convertInt+0x57>
cmpl   $0x2,-0x20(%rbp)
jle    119e <convertInt+0x7e>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe7a(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1245 <convertInt+0x125>
cmpl   $0x2,-0x20(%rbp)
jne    1240 <convertInt+0x120>
movsbl -0x16(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x48,%eax
je     1212 <convertInt+0xf2>
jmp    11bd <convertInt+0x9d>
mov    -0x24(%rbp),%eax
sub    $0x4d,%eax
je     1223 <convertInt+0x103>
jmp    11ce <convertInt+0xae>
mov    -0x24(%rbp),%eax
sub    $0x53,%eax
je     1231 <convertInt+0x111>
jmp    11df <convertInt+0xbf>
mov    -0x24(%rbp),%eax
sub    $0x68,%eax
je     1212 <convertInt+0xf2>
jmp    11f0 <convertInt+0xd0>
mov    -0x24(%rbp),%eax
sub    $0x6d,%eax
je     1223 <convertInt+0x103>
jmp    1201 <convertInt+0xe1>
mov    -0x24(%rbp),%eax
sub    $0x73,%eax
je     1231 <convertInt+0x111>
jmp    1236 <convertInt+0x116>
mov    -0x10(%rbp),%rax
imul   $0xe10,(%rax),%ecx
mov    %ecx,(%rax)
jmp    123b <convertInt+0x11b>
mov    -0x10(%rbp),%rax
imul   $0x3c,(%rax),%ecx
mov    %ecx,(%rax)
jmp    123b <convertInt+0x11b>
jmp    1236 <convertInt+0x116>
jmp    123b <convertInt+0x11b>
jmp    1240 <convertInt+0x120>
jmp    1245 <convertInt+0x125>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertInt>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movb   $0x0,0xc(%rsp)
movl   $0x63256925,0x8(%rsp)
63
mov    (%rsi),%ebp
lea    0x8(%rsp),%rsi
lea    0x7(%rsp),%rcx
mov    %r14,%rdx
call   1040 <sscanf@plt>
lea    -0x3(%rax),%ecx
cmp    $0xfffffffd,%ecx
ja     1174 <convertInt+0x54>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xf36(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    %ebp,(%r14)
jmp    119f <convertInt+0x7f>
cmp    $0x2,%eax
jne    119f <convertInt+0x7f>
movsbl 0x7(%rsp),%eax
add    $0xffffffb8,%eax
cmp    $0x25,%eax
ja     119f <convertInt+0x7f>
lea    0xe73(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
imul   $0xe10,(%r14),%ebp
jmp    116f <convertInt+0x4f>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
imul   $0x3c,(%r14),%ebp
jmp    116f <convertInt+0x4f>

LLVM IR (-O0):
@__const.convertInt.format = [5 x i8] c"%i%c\00"
@stderr = global i32 0
@.str = [28 x i8] c"Conversion of '%s' failed.\0A\00"
define void @convertInt(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [5 x i8]
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%9 = bitcast [5 x i8]* %5 to i8*
%10 = load i32*, i32** %4
%11 = load i32, i32* %10
store i32 %11, i32* %7
%12 = load i8*, i8** %3
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%14 = load i32*, i32** %4
%15 = call i32 @sscanf(i8* %12, i8* %13, i32* %14, i8* %6)
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = icmp slt i32 %16, 1
br i1 %17, label %21, label %18
18: ; preds = %2
%19 = load i32, i32* %8
%20 = icmp sgt i32 %19, 2
br i1 %20, label %21, label %27
21: ; preds = %18, %2
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %3
%24 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = load i32, i32* %7
%26 = load i32*, i32** %4
store i32 %25, i32* %26
br label %45
27: ; preds = %18
%28 = load i32, i32* %8
%29 = icmp eq i32 %28, 2
br i1 %29, label %30, label %44
30: ; preds = %27
%31 = load i8, i8* %6
%32 = sext i8 %31 to i32
switch i32 %32, label %42 [
i32 72, label %33
i32 104, label %33
i32 77, label %37
i32 109, label %37
i32 83, label %41
i32 115, label %41
]
33: ; preds = %30, %30
%34 = load i32*, i32** %4
%35 = load i32, i32* %34
%36 = mul nsw i32 %35, 3600
store i32 %36, i32* %34
br label %43
37: ; preds = %30, %30
%38 = load i32*, i32** %4
%39 = load i32, i32* %38
%40 = mul nsw i32 %39, 60
store i32 %40, i32* %38
br label %43
41: ; preds = %30, %30
br label %42
42: ; preds = %30, %41
br label %43
43: ; preds = %42, %37, %33
br label %44
44: ; preds = %43, %27
br label %45
45: ; preds = %44, %21
ret void
}

LLVM IR (-O2):
@__const.convertInt.format = [5 x i8] c"%i%c\00"
@stderr = global i32 0
@.str = [28 x i8] c"Conversion of '%s' failed.\0A\00"
define void @convertInt(i8* %0, i32* %1) {
%3 = alloca [5 x i8]
%4 = alloca i8
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%6 = load i32, i32* %1
%7 = call i32 @sscanf(i8* %0, i8* %5, i32* %1, i8* %4)
%8 = add i32 %7, -3
%9 = icmp ult i32 %8, -2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %24
13: ; preds = %2
%14 = icmp eq i32 %7, 2
br i1 %14, label %15, label %26
15: ; preds = %13
%16 = load i8, i8* %4
%17 = sext i8 %16 to i32
switch i32 %17, label %26 [
i32 72, label %18
i32 104, label %18
i32 77, label %21
i32 109, label %21
]
18: ; preds = %15, %15
%19 = load i32, i32* %1
%20 = mul nsw i32 %19, 3600
br label %24
21: ; preds = %15, %15
%22 = load i32, i32* %1
%23 = mul nsw i32 %22, 60
br label %24
24: ; preds = %10, %18, %21
%25 = phi i32 [ %23, %21 ], [ %20, %18 ], [ %6, %10 ]
store i32 %25, i32* %1
br label %26
26: ; preds = %24, %13, %15
ret void
}