#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*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ timlib_pad_time_four(char *);
void test_pad_time(void) {
  char time[5];
  sprintf(time, "0");
  timlib_pad_time_four(time);
  printf("should be 0000: is %s\n", time);
  sprintf(time, "000");
  timlib_pad_time_four(time);
  printf("should be 0000: is %s\n", time);
}


x86 assembly (clang, -O0):
<test_pad_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x5(%rbp),%rdi
lea    0xed6(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x5(%rbp),%rdi
call   1030 <timlib_pad_time_four@plt>
lea    -0x5(%rbp),%rsi
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
lea    -0x5(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x5(%rbp),%rdi
call   1030 <timlib_pad_time_four@plt>
lea    -0x5(%rbp),%rsi
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_pad_time>:
push   %r14
push   %rbx
push   %rax
movw   $0x30,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <timlib_pad_time_four@plt>
lea    0xec4(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
movl   $0x303030,(%rsp)
mov    %rbx,%rdi
call   1030 <timlib_pad_time_four@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"0\00"
@.str.1 = [23 x i8] c"should be 0000: is %s\0A\00"
@.str.2 = [4 x i8] c"000\00"
define void @test_pad_time() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = call i32 @sprintf(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%5 = call i32 @timlib_pad_time_four(i8* %4)
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%7 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%9 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%11 = call i32 @timlib_pad_time_four(i8* %10)
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %12)
ret void
}

LLVM IR (-O2):
@.str.1 = [23 x i8] c"should be 0000: is %s\0A\00"
define void @test_pad_time() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = bitcast [5 x i8]* %1 to i16*
store i16 48, i16* %3
%4 = call i32 @timlib_pad_time_four(i8* %2)
%5 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = bitcast [5 x i8]* %1 to i32*
store i32 3158064, i32* %6
%7 = call i32 @timlib_pad_time_four(i8* %2)
%8 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret void
}