#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int rm_eo;
  size_t rm_so;
};
typedef TYPE_1__ regmatch_t;

/* Variables and functions */
int atol(char *);
char *index(char *, char);
int /*<<< orphan*/ strncpy(char *, char *, unsigned int);
int getConfigOptionDuration(long int *duration, char line[],
                            regmatch_t *submatch) {
  long int dur;
  int absolute_time = submatch[1].rm_eo - submatch[1].rm_so;
  char num[32];
  char *p;
  unsigned int len = ((submatch[2].rm_eo - submatch[2].rm_so) < (32 - 1)
                          ? (submatch[2].rm_eo - submatch[2].rm_so)
                          : (32 - 1));
  strncpy(num, &line[submatch[2].rm_so], len);
  num[len] = '\0';
  if ((p = index(num, ':')) == NULL) {
    dur = atol(num);
  } else {
    *p++ = '\0';
    dur = atol(num) * 3600 + atol(p) * 60;
  }
  if (absolute_time)
    dur *= -1;
  *duration = dur;
  return 0;
}


x86 assembly (clang, -O0):
<getConfigOptionDuration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movslq 0x10(%rax),%rax
mov    -0x18(%rbp),%rcx
sub    0x18(%rcx),%rax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movslq 0x20(%rax),%rax
mov    -0x18(%rbp),%rcx
sub    0x28(%rcx),%rax
cmp    $0x1f,%rax
jae    118a <getConfigOptionDuration+0x5a>
mov    -0x18(%rbp),%rax
movslq 0x20(%rax),%rax
mov    -0x18(%rbp),%rcx
sub    0x28(%rcx),%rax
mov    %rax,-0x68(%rbp)
jmp    1198 <getConfigOptionDuration+0x68>
mov    $0x1f,%eax
mov    %rax,-0x68(%rbp)
jmp    1198 <getConfigOptionDuration+0x68>
mov    -0x68(%rbp),%rax
mov    %eax,-0x5c(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
add    0x28(%rax),%rsi
mov    -0x5c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x5c(%rbp),%eax
movb   $0x0,-0x50(%rbp,%rax,1)
lea    -0x50(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <index@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    11ef <getConfigOptionDuration+0xbf>
lea    -0x50(%rbp),%rdi
call   1050 <atol@plt>
cltq
mov    %rax,-0x20(%rbp)
jmp    122c <getConfigOptionDuration+0xfc>
mov    -0x58(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x58(%rbp)
movb   $0x0,(%rax)
lea    -0x50(%rbp),%rdi
call   1050 <atol@plt>
imul   $0xe10,%eax,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x58(%rbp),%rdi
call   1050 <atol@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
imul   $0x3c,%ecx,%ecx
add    %ecx,%eax
cltq
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     123f <getConfigOptionDuration+0x10f>
imul   $0xffffffffffffffff,-0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getConfigOptionDuration>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r14
mov    0x10(%rdx),%r12d
mov    0x18(%rdx),%r13
movslq 0x20(%rdx),%rax
mov    0x28(%rdx),%rcx
sub    %rcx,%rax
cmp    $0x1f,%rax
mov    $0x1f,%ebx
cmovb  %rax,%rbx
add    %rcx,%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    %ebx,%edx
call   1030 <strncpy@plt>
movb   $0x0,(%rsp,%rbx,1)
mov    %r15,%rdi
mov    $0x3a,%esi
call   1040 <index@plt>
test   %rax,%rax
je     11ae <getConfigOptionDuration+0x7e>
mov    %rax,%rbx
add    $0x1,%rbx
movb   $0x0,(%rax)
mov    %rsp,%rdi
call   1050 <atol@plt>
imul   $0xe10,%eax,%ebp
mov    %rbx,%rdi
call   1050 <atol@plt>
imul   $0x3c,%eax,%eax
add    %ebp,%eax
jmp    11b6 <getConfigOptionDuration+0x86>
mov    %rsp,%rdi
call   1050 <atol@plt>
cltq
mov    %rax,%rcx
neg    %rcx
cmp    %r13d,%r12d
cmove  %rax,%rcx
mov    %rcx,(%r14)
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i64 }
define i32 @getConfigOptionDuration(i64* %0, i8* %1, %struct.TYPE_3__* %2) {
%4 = alloca i64*
%5 = alloca i8*
%6 = alloca %struct.TYPE_3__*
%7 = alloca i64
%8 = alloca i32
%9 = alloca [32 x i8]
%10 = alloca i8*
%11 = alloca i32
store i64* %0, i64** %4
store i8* %1, i8** %5
store %struct.TYPE_3__* %2, %struct.TYPE_3__** %6
%12 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i64 1
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = sext i32 %15 to i64
%17 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i64 1
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %18, i32 0, i32 1
%20 = load i64, i64* %19
%21 = sub i64 %16, %20
%22 = trunc i64 %21 to i32
store i32 %22, i32* %8
%23 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i64 2
%25 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %24, i32 0, i32 0
%26 = load i32, i32* %25
%27 = sext i32 %26 to i64
%28 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %28, i64 2
%30 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %29, i32 0, i32 1
%31 = load i64, i64* %30
%32 = sub i64 %27, %31
%33 = icmp ult i64 %32, 31
br i1 %33, label %34, label %45
34: ; preds = %3
%35 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%36 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %35, i64 2
%37 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %36, i32 0, i32 0
%38 = load i32, i32* %37
%39 = sext i32 %38 to i64
%40 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%41 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %40, i64 2
%42 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %41, i32 0, i32 1
%43 = load i64, i64* %42
%44 = sub i64 %39, %43
br label %46
45: ; preds = %3
br label %46
46: ; preds = %45, %34
%47 = phi i64 [ %44, %34 ], [ 31, %45 ]
%48 = trunc i64 %47 to i32
store i32 %48, i32* %11
%49 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%50 = load i8*, i8** %5
%51 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%52 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %51, i64 2
%53 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %52, i32 0, i32 1
%54 = load i64, i64* %53
%55 = getelementptr inbounds i8, i8* %50, i64 %54
%56 = load i32, i32* %11
%57 = call i32 @strncpy(i8* %49, i8* %55, i32 %56)
%58 = load i32, i32* %11
%59 = zext i32 %58 to i64
%60 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 %59
store i8 0, i8* %60
%61 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%62 = call i8* @index(i8* %61, i8 signext 58)
store i8* %62, i8** %10
%63 = icmp eq i8* %62, null
br i1 %63, label %64, label %68
64: ; preds = %46
%65 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%66 = call i32 @atol(i8* %65)
%67 = sext i32 %66 to i64
store i64 %67, i64* %7
br label %79
68: ; preds = %46
%69 = load i8*, i8** %10
%70 = getelementptr inbounds i8, i8* %69, i32 1
store i8* %70, i8** %10
store i8 0, i8* %69
%71 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%72 = call i32 @atol(i8* %71)
%73 = mul nsw i32 %72, 3600
%74 = load i8*, i8** %10
%75 = call i32 @atol(i8* %74)
%76 = mul nsw i32 %75, 60
%77 = add nsw i32 %73, %76
%78 = sext i32 %77 to i64
store i64 %78, i64* %7
br label %79
79: ; preds = %68, %64
%80 = load i32, i32* %8
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %79
%83 = load i64, i64* %7
%84 = mul nsw i64 %83, -1
store i64 %84, i64* %7
br label %85
85: ; preds = %82, %79
%86 = load i64, i64* %7
%87 = load i64*, i64** %4
store i64 %86, i64* %87
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i64 }
define i32 @getConfigOptionDuration(i64* nocapture writeonly %0, i8* %1, %struct.TYPE_3__* nocapture %2) {
%4 = alloca [32 x i8]
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 1, i32 0
%6 = load i32, i32* %5
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 1, i32 1
%8 = load i64, i64* %7
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 2, i32 0
%11 = load i32, i32* %10
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 2, i32 1
%14 = load i64, i64* %13
%15 = sub i64 %12, %14
%16 = icmp ult i64 %15, 31
%17 = select i1 %16, i64 %15, i64 31
%18 = trunc i64 %17 to i32
%19 = getelementptr inbounds i8, i8* %1, i64 %14
%20 = call i32 @strncpy(i8* %9, i8* %19, i32 %18)
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 %17
store i8 0, i8* %21
%22 = call i8* @index(i8* %9, i8 signext 58)
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %26
24: ; preds = %3
%25 = call i32 @atol(i8* %9)
br label %33
26: ; preds = %3
%27 = getelementptr inbounds i8, i8* %22, i64 1
store i8 0, i8* %22
%28 = call i32 @atol(i8* %9)
%29 = mul nsw i32 %28, 3600
%30 = call i32 @atol(i8* %27)
%31 = mul nsw i32 %30, 60
%32 = add nsw i32 %31, %29
br label %33
33: ; preds = %26, %24
%34 = phi i32 [ %25, %24 ], [ %32, %26 ]
%35 = trunc i64 %8 to i32
%36 = sext i32 %34 to i64
%37 = icmp eq i32 %6, %35
%38 = sub nsw i64 0, %36
%39 = select i1 %37, i64 %36, i64 %38
store i64 %39, i64* %0
ret i32 0
}