#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 timespec {
  int tv_sec;
  scalar_t__ tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ _string_to_timespec(char *, struct timespec *);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
void test_string_to_timespec_should_be_able_to_parse_all_regular_time_units(
    void) {
  {
    struct timespec time;
    assert(_string_to_timespec("1", &time));
    assert(time.tv_sec == (1) && time.tv_nsec == 0 &&
           "Seconds parsed from "
           "1"
           " did not match expected");
  };
  {
    struct timespec time;
    assert(_string_to_timespec("1s", &time));
    assert(time.tv_sec == (1) && time.tv_nsec == 0 &&
           "Seconds parsed from "
           "1s"
           " did not match expected");
  };
  {
    struct timespec time;
    assert(_string_to_timespec("1m", &time));
    assert(time.tv_sec == (60) && time.tv_nsec == 0 &&
           "Seconds parsed from "
           "1m"
           " did not match expected");
  };
  {
    struct timespec time;
    assert(_string_to_timespec("1h", &time));
    assert(time.tv_sec == (60 * 60) && time.tv_nsec == 0 &&
           "Seconds parsed from "
           "1h"
           " did not match expected");
  };
  {
    struct timespec time;
    assert(_string_to_timespec("1d", &time));
    assert(time.tv_sec == (24 * 60 * 60) && time.tv_nsec == 0 &&
           "Seconds parsed from "
           "1d"
           " did not match expected");
  };
  {
    struct timespec time;
    assert(_string_to_timespec("1d1h1m1s", &time));
    assert(time.tv_sec == (24 * 60 * 60 + 60 * 60 + 60 + 1) &&
           time.tv_nsec == 0 &&
           "Seconds parsed from "
           "1d1h1m1s"
           " did not match expected");
  };
}


x86 assembly (clang, -O0):
<test_string_to_timespec_should_be_able_to_parse_all_regular_time_units>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    0xed1(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <_string_to_timespec@plt>
mov    %eax,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmpl   $0x1,-0x10(%rbp)
mov    %al,-0x61(%rbp)
jne    1168 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x48>
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x61(%rbp)
jne    1168 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x48>
mov    $0x1,%al
mov    %al,-0x61(%rbp)
jmp    1168 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x48>
mov    -0x61(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xf7a(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <_string_to_timespec@plt>
mov    %eax,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmpl   $0x1,-0x20(%rbp)
mov    %al,-0x62(%rbp)
jne    11b5 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x95>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x62(%rbp)
jne    11b5 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x95>
mov    $0x1,%al
mov    %al,-0x62(%rbp)
jmp    11b5 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x95>
mov    -0x62(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe94(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <_string_to_timespec@plt>
mov    %eax,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmpl   $0x3c,-0x30(%rbp)
mov    %al,-0x63(%rbp)
jne    1202 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0xe2>
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x63(%rbp)
jne    1202 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0xe2>
mov    $0x1,%al
mov    %al,-0x63(%rbp)
jmp    1202 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0xe2>
mov    -0x63(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe78(%rip),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <_string_to_timespec@plt>
mov    %eax,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmpl   $0xe10,-0x40(%rbp)
mov    %al,-0x64(%rbp)
jne    1252 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x132>
xor    %eax,%eax
cmpq   $0x0,-0x38(%rbp)
mov    %al,-0x64(%rbp)
jne    1252 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x132>
mov    $0x1,%al
mov    %al,-0x64(%rbp)
jmp    1252 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x132>
mov    -0x64(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe59(%rip),%rdi
lea    -0x50(%rbp),%rsi
call   1030 <_string_to_timespec@plt>
mov    %eax,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmpl   $0x15180,-0x50(%rbp)
mov    %al,-0x65(%rbp)
jne    12a2 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x182>
xor    %eax,%eax
cmpq   $0x0,-0x48(%rbp)
mov    %al,-0x65(%rbp)
jne    12a2 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x182>
mov    $0x1,%al
mov    %al,-0x65(%rbp)
jmp    12a2 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x182>
mov    -0x65(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe3a(%rip),%rdi
lea    -0x60(%rbp),%rsi
call   1030 <_string_to_timespec@plt>
mov    %eax,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmpl   $0x15fcd,-0x60(%rbp)
mov    %al,-0x66(%rbp)
jne    12f2 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x1d2>
xor    %eax,%eax
cmpq   $0x0,-0x58(%rbp)
mov    %al,-0x66(%rbp)
jne    12f2 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x1d2>
mov    $0x1,%al
mov    %al,-0x66(%rbp)
jmp    12f2 <test_string_to_timespec_should_be_able_to_parse_all_regular_time_units+0x1d2>
mov    -0x66(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_string_to_timespec_should_be_able_to_parse_all_regular_time_units>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <_string_to_timespec@plt>
mov    %eax,%edi
call   1040 <assert@plt>
cmpl   $0x1,0x8(%rsp)
sete   %al
cmpq   $0x0,0x10(%rsp)
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
lea    0xeb3(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <_string_to_timespec@plt>
mov    %eax,%edi
call   1040 <assert@plt>
cmpl   $0x1,0x8(%rsp)
sete   %al
cmpq   $0x0,0x10(%rsp)
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
lea    0xe71(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <_string_to_timespec@plt>
mov    %eax,%edi
call   1040 <assert@plt>
cmpl   $0x3c,0x8(%rsp)
sete   %al
cmpq   $0x0,0x10(%rsp)
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
lea    0xe41(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <_string_to_timespec@plt>
mov    %eax,%edi
call   1040 <assert@plt>
cmpl   $0xe10,0x8(%rsp)
sete   %al
cmpq   $0x0,0x10(%rsp)
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
lea    0xe0e(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <_string_to_timespec@plt>
mov    %eax,%edi
call   1040 <assert@plt>
cmpl   $0x15180,0x8(%rsp)
sete   %al
cmpq   $0x0,0x10(%rsp)
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
lea    0xddb(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <_string_to_timespec@plt>
mov    %eax,%edi
call   1040 <assert@plt>
cmpl   $0x15fcd,0x8(%rsp)
sete   %al
cmpq   $0x0,0x10(%rsp)
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i64 }
@.str = [2 x i8] c"1\00"
@.str.1 = [45 x i8] c"Seconds parsed from 1 did not match expected\00"
@.str.2 = [3 x i8] c"1s\00"
@.str.3 = [46 x i8] c"Seconds parsed from 1s did not match expected\00"
@.str.4 = [3 x i8] c"1m\00"
@.str.5 = [46 x i8] c"Seconds parsed from 1m did not match expected\00"
@.str.6 = [3 x i8] c"1h\00"
@.str.7 = [46 x i8] c"Seconds parsed from 1h did not match expected\00"
@.str.8 = [3 x i8] c"1d\00"
@.str.9 = [46 x i8] c"Seconds parsed from 1d did not match expected\00"
@.str.10 = [9 x i8] c"1d1h1m1s\00"
@.str.11 = [52 x i8] c"Seconds parsed from 1d1h1m1s did not match expected\00"
define void @test_string_to_timespec_should_be_able_to_parse_all_regular_time_units() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timespec
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
%5 = alloca %struct.timespec
%6 = alloca %struct.timespec
%7 = call i32 @_string_to_timespec(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.timespec* %1)
%8 = call i32 @assert(i32 %7)
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %0
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%14 = load i64, i64* %13
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
br label %17
17: ; preds = %16, %12, %0
%18 = phi i1 [ false, %12 ], [ false, %0 ], [ true, %16 ]
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 @_string_to_timespec(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.timespec* %2)
%22 = call i32 @assert(i32 %21)
%23 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %31
26: ; preds = %17
%27 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
%28 = load i64, i64* %27
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
br label %31
31: ; preds = %30, %26, %17
%32 = phi i1 [ false, %26 ], [ false, %17 ], [ true, %30 ]
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = call i32 @_string_to_timespec(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), %struct.timespec* %3)
%36 = call i32 @assert(i32 %35)
%37 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
%38 = load i32, i32* %37
%39 = icmp eq i32 %38, 60
br i1 %39, label %40, label %45
40: ; preds = %31
%41 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 1
%42 = load i64, i64* %41
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %40
br label %45
45: ; preds = %44, %40, %31
%46 = phi i1 [ false, %40 ], [ false, %31 ], [ true, %44 ]
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = call i32 @_string_to_timespec(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), %struct.timespec* %4)
%50 = call i32 @assert(i32 %49)
%51 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%52 = load i32, i32* %51
%53 = icmp eq i32 %52, 3600
br i1 %53, label %54, label %59
54: ; preds = %45
%55 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
%56 = load i64, i64* %55
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %54
br label %59
59: ; preds = %58, %54, %45
%60 = phi i1 [ false, %54 ], [ false, %45 ], [ true, %58 ]
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = call i32 @_string_to_timespec(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), %struct.timespec* %5)
%64 = call i32 @assert(i32 %63)
%65 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
%66 = load i32, i32* %65
%67 = icmp eq i32 %66, 86400
br i1 %67, label %68, label %73
68: ; preds = %59
%69 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
%70 = load i64, i64* %69
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %73
72: ; preds = %68
br label %73
73: ; preds = %72, %68, %59
%74 = phi i1 [ false, %68 ], [ false, %59 ], [ true, %72 ]
%75 = zext i1 %74 to i32
%76 = call i32 @assert(i32 %75)
%77 = call i32 @_string_to_timespec(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), %struct.timespec* %6)
%78 = call i32 @assert(i32 %77)
%79 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%80 = load i32, i32* %79
%81 = icmp eq i32 %80, 90061
br i1 %81, label %82, label %87
82: ; preds = %73
%83 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
%84 = load i64, i64* %83
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %87
86: ; preds = %82
br label %87
87: ; preds = %86, %82, %73
%88 = phi i1 [ false, %82 ], [ false, %73 ], [ true, %86 ]
%89 = zext i1 %88 to i32
%90 = call i32 @assert(i32 %89)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i64 }
@.str = [2 x i8] c"1\00"
@.str.2 = [3 x i8] c"1s\00"
@.str.4 = [3 x i8] c"1m\00"
@.str.6 = [3 x i8] c"1h\00"
@.str.8 = [3 x i8] c"1d\00"
@.str.10 = [9 x i8] c"1d1h1m1s\00"
define void @test_string_to_timespec_should_be_able_to_parse_all_regular_time_units() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timespec
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
%5 = alloca %struct.timespec
%6 = alloca %struct.timespec
%7 = bitcast %struct.timespec* %1 to i8*
%8 = call i32 @_string_to_timespec(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.timespec* %1)
%9 = call i32 @assert(i32 %8)
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 1
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%14 = load i64, i64* %13
%15 = icmp eq i64 %14, 0
%16 = select i1 %12, i1 %15, i1 false
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = bitcast %struct.timespec* %2 to i8*
%20 = call i32 @_string_to_timespec(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.timespec* %2)
%21 = call i32 @assert(i32 %20)
%22 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 1
%25 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%26 = load i64, i64* %25
%27 = icmp eq i64 %26, 0
%28 = select i1 %24, i1 %27, i1 false
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = bitcast %struct.timespec* %3 to i8*
%32 = call i32 @_string_to_timespec(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), %struct.timespec* %3)
%33 = call i32 @assert(i32 %32)
%34 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%35 = load i32, i32* %34
%36 = icmp eq i32 %35, 60
%37 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%38 = load i64, i64* %37
%39 = icmp eq i64 %38, 0
%40 = select i1 %36, i1 %39, i1 false
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = bitcast %struct.timespec* %4 to i8*
%44 = call i32 @_string_to_timespec(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), %struct.timespec* %4)
%45 = call i32 @assert(i32 %44)
%46 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
%47 = load i32, i32* %46
%48 = icmp eq i32 %47, 3600
%49 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 1
%50 = load i64, i64* %49
%51 = icmp eq i64 %50, 0
%52 = select i1 %48, i1 %51, i1 false
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = bitcast %struct.timespec* %5 to i8*
%56 = call i32 @_string_to_timespec(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), %struct.timespec* %5)
%57 = call i32 @assert(i32 %56)
%58 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
%59 = load i32, i32* %58
%60 = icmp eq i32 %59, 86400
%61 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
%62 = load i64, i64* %61
%63 = icmp eq i64 %62, 0
%64 = select i1 %60, i1 %63, i1 false
%65 = zext i1 %64 to i32
%66 = call i32 @assert(i32 %65)
%67 = bitcast %struct.timespec* %6 to i8*
%68 = call i32 @_string_to_timespec(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), %struct.timespec* %6)
%69 = call i32 @assert(i32 %68)
%70 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%71 = load i32, i32* %70
%72 = icmp eq i32 %71, 90061
%73 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 1
%74 = load i64, i64* %73
%75 = icmp eq i64 %74, 0
%76 = select i1 %72, i1 %75, i1 false
%77 = zext i1 %76 to i32
%78 = call i32 @assert(i32 %77)
ret void
}