#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;
  int /*<<< orphan*/ tv_nsec;
};
typedef int /*<<< orphan*/ out;

/* Variables and functions */
int /*<<< orphan*/ _timespec_to_string(struct timespec *, char *, int);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
void test_timespec_to_string_should_be_able_to_output_all_time_units(void) {
  {
    char out[32] = {0};
    struct timespec time = {.tv_sec = (0), .tv_nsec = 0};
    _timespec_to_string(&time, out, sizeof(out));
    assert(strcmp(out, ("0s")) == 0 &&
           "Output time value did not match expected "
           "0s");
  };
  {
    char out[32] = {0};
    struct timespec time = {.tv_sec = (1), .tv_nsec = 0};
    _timespec_to_string(&time, out, sizeof(out));
    assert(strcmp(out, ("1s")) == 0 &&
           "Output time value did not match expected "
           "1s");
  };
  {
    char out[32] = {0};
    struct timespec time = {.tv_sec = (60), .tv_nsec = 0};
    _timespec_to_string(&time, out, sizeof(out));
    assert(strcmp(out, ("1m")) == 0 &&
           "Output time value did not match expected "
           "1m");
  };
  {
    char out[32] = {0};
    struct timespec time = {.tv_sec = (60 * 60), .tv_nsec = 0};
    _timespec_to_string(&time, out, sizeof(out));
    assert(strcmp(out, ("1h")) == 0 &&
           "Output time value did not match expected "
           "1h");
  };
  {
    char out[32] = {0};
    struct timespec time = {.tv_sec = (24 * 60 * 60), .tv_nsec = 0};
    _timespec_to_string(&time, out, sizeof(out));
    assert(strcmp(out, ("1d")) == 0 &&
           "Output time value did not match expected "
           "1d");
  };
  {
    char out[32] = {0};
    struct timespec time = {.tv_sec = (24 * 60 * 60 + 60 * 60 + 60 + 1),
                            .tv_nsec = 0};
    _timespec_to_string(&time, out, sizeof(out));
    assert(strcmp(out, ("1d1h1m1s")) == 0 &&
           "Output time value did not match expected "
           "1d1h1m1s");
  };
}


x86 assembly (clang, -O0):
<test_timespec_to_string_should_be_able_to_output_all_time_units>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdi
mov    $0x20,%edx
call   1060 <_timespec_to_string@plt>
lea    -0x20(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x119(%rbp)
jne    11af <test_timespec_to_string_should_be_able_to_output_all_time_units+0x6f>
mov    $0x1,%al
mov    %al,-0x119(%rbp)
jmp    11af <test_timespec_to_string_should_be_able_to_output_all_time_units+0x6f>
mov    -0x119(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    0xf3a(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rsi
lea    -0x58(%rbp),%rdi
mov    $0x20,%edx
call   1060 <_timespec_to_string@plt>
lea    -0x50(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11a(%rbp)
jne    121e <test_timespec_to_string_should_be_able_to_output_all_time_units+0xde>
mov    $0x1,%al
mov    %al,-0x11a(%rbp)
jmp    121e <test_timespec_to_string_should_be_able_to_output_all_time_units+0xde>
mov    -0x11a(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    0xed3(%rip),%rax
mov    %rax,-0x88(%rbp)
lea    -0x80(%rbp),%rsi
lea    -0x88(%rbp),%rdi
mov    $0x20,%edx
call   1060 <_timespec_to_string@plt>
lea    -0x80(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11b(%rbp)
jne    1293 <test_timespec_to_string_should_be_able_to_output_all_time_units+0x153>
mov    $0x1,%al
mov    %al,-0x11b(%rbp)
jmp    1293 <test_timespec_to_string_should_be_able_to_output_all_time_units+0x153>
mov    -0x11b(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    0xe63(%rip),%rax
mov    %rax,-0xb8(%rbp)
lea    -0xb0(%rbp),%rsi
lea    -0xb8(%rbp),%rdi
mov    $0x20,%edx
call   1060 <_timespec_to_string@plt>
lea    -0xb0(%rbp),%rdi
lea    0xdc3(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11c(%rbp)
jne    1311 <test_timespec_to_string_should_be_able_to_output_all_time_units+0x1d1>
mov    $0x1,%al
mov    %al,-0x11c(%rbp)
jmp    1311 <test_timespec_to_string_should_be_able_to_output_all_time_units+0x1d1>
mov    -0x11c(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    0xded(%rip),%rax
mov    %rax,-0xe8(%rbp)
lea    -0xe0(%rbp),%rsi
lea    -0xe8(%rbp),%rdi
mov    $0x20,%edx
call   1060 <_timespec_to_string@plt>
lea    -0xe0(%rbp),%rdi
lea    0xd71(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11d(%rbp)
jne    138f <test_timespec_to_string_should_be_able_to_output_all_time_units+0x24f>
mov    $0x1,%al
mov    %al,-0x11d(%rbp)
jmp    138f <test_timespec_to_string_should_be_able_to_output_all_time_units+0x24f>
mov    -0x11d(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    0xd77(%rip),%rax
mov    %rax,-0x118(%rbp)
lea    -0x110(%rbp),%rsi
lea    -0x118(%rbp),%rdi
mov    $0x20,%edx
call   1060 <_timespec_to_string@plt>
lea    -0x110(%rbp),%rdi
lea    0xd1f(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11e(%rbp)
jne    140d <test_timespec_to_string_should_be_able_to_output_all_time_units+0x2cd>
mov    $0x1,%al
mov    %al,-0x11e(%rbp)
jmp    140d <test_timespec_to_string_should_be_able_to_output_all_time_units+0x2cd>
mov    -0x11e(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_timespec_to_string_should_be_able_to_output_all_time_units>:
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x20,%edx
call   1050 <_timespec_to_string@plt>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x1,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x20,%edx
call   1050 <_timespec_to_string@plt>
lea    0xe5f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x3c,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x20,%edx
call   1050 <_timespec_to_string@plt>
lea    0xe06(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0xe10,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x20,%edx
call   1050 <_timespec_to_string@plt>
lea    0xdbf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x15180,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x20,%edx
call   1050 <_timespec_to_string@plt>
lea    0xd78(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x15fcd,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x20,%edx
call   1050 <_timespec_to_string@plt>
lea    0xd31(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
add    $0x30,%rsp
pop    %rbx
ret

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

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