#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 timeval {
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ rand();
int /*<<< orphan*/ sprintf(char *, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ srand(int);
char *uwid_key_gen() {
  struct timeval tv;
  char seq[20];
  int i;
  for (i = 0; i < 10; i++) {
    gettimeofday(&tv, NULL);
    srand(tv.tv_usec);
    sprintf(seq, "%X%X", tv.tv_usec, rand());
  }
  return seq;
}


x86 assembly (clang, -O0):
<uwid_key_gen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x24(%rbp)
cmpl   $0xa,-0x24(%rbp)
jge    11a6 <uwid_key_gen+0x66>
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x8(%rbp),%edi
call   1040 <srand@plt>
lea    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    %eax,%ecx
lea    0xe6d(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114f <uwid_key_gen+0xf>
lea    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uwid_key_gen>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
lea    0xe8e(%rip),%r15
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <sprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <sprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <sprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <sprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <sprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <sprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <sprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <sprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <sprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <sprintf@plt>
mov    %rbx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [5 x i8] c"%X%X\00"
define i8* @uwid_key_gen() {
%1 = alloca %struct.timeval
%2 = alloca [20 x i8]
%3 = alloca i32
store i32 0, i32* %3
br label %4
4: ; preds = %17, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %20
7: ; preds = %4
%8 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%10 = load i32, i32* %9
%11 = call i32 @srand(i32 %10)
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%14 = load i32, i32* %13
%15 = call i32 (...) @rand()
%16 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15)
br label %17
17: ; preds = %7
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %4
20: ; preds = %4
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
ret i8* %21
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [5 x i8] c"%X%X\00"
define noalias i8* @uwid_key_gen() {
%1 = alloca %struct.timeval
%2 = alloca [20 x i8]
%3 = bitcast %struct.timeval* %1 to i8*
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%6 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%7 = load i32, i32* %5
%8 = tail call i32 @srand(i32 %7)
%9 = tail call i32 (...) @rand()
%10 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9)
%11 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%12 = load i32, i32* %5
%13 = tail call i32 @srand(i32 %12)
%14 = tail call i32 (...) @rand()
%15 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %14)
%16 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%17 = load i32, i32* %5
%18 = tail call i32 @srand(i32 %17)
%19 = tail call i32 (...) @rand()
%20 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %19)
%21 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%22 = load i32, i32* %5
%23 = tail call i32 @srand(i32 %22)
%24 = tail call i32 (...) @rand()
%25 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %24)
%26 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%27 = load i32, i32* %5
%28 = tail call i32 @srand(i32 %27)
%29 = tail call i32 (...) @rand()
%30 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %29)
%31 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%32 = load i32, i32* %5
%33 = tail call i32 @srand(i32 %32)
%34 = tail call i32 (...) @rand()
%35 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %32, i32 %34)
%36 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%37 = load i32, i32* %5
%38 = tail call i32 @srand(i32 %37)
%39 = tail call i32 (...) @rand()
%40 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %37, i32 %39)
%41 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%42 = load i32, i32* %5
%43 = tail call i32 @srand(i32 %42)
%44 = tail call i32 (...) @rand()
%45 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %42, i32 %44)
%46 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%47 = load i32, i32* %5
%48 = tail call i32 @srand(i32 %47)
%49 = tail call i32 (...) @rand()
%50 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %47, i32 %49)
%51 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%52 = load i32, i32* %5
%53 = tail call i32 @srand(i32 %52)
%54 = tail call i32 (...) @rand()
%55 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %52, i32 %54)
ret i8* %4
}