#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 */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
int getpid();
int /*<<< orphan*/ printf(char *, int, int);
int rand();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
void c_sleep() {
  time_t t;
  srand((unsigned)time(&t) * getpid());
  int c_time = ((rand() % 10) + 1);
  printf("Processo %i criado, irá dormir por %i \n", getpid(), c_time);
  sleep(c_time);
}


x86 assembly (clang, -O0):
<c_sleep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x4(%rbp),%rdi
call   1060 <time@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xc(%rbp),%edi
imul   %eax,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x8(%rbp),%edx
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1070 <sleep@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_sleep>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
call   1060 <time@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <getpid@plt>
imul   %eax,%ebx
mov    %ebx,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x1,%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xe45(%rip),%rdi
mov    %eax,%esi
mov    %ebx,%edx
call   1040 <printf@plt>
mov    %ebx,%edi
call   1070 <sleep@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Processo %i criado, ir\C3\A1 dormir por %i \0A\00"
define void @c_sleep() {
%1 = alloca i32
%2 = alloca i32
%3 = call i64 @time(i32* %1)
%4 = trunc i64 %3 to i32
%5 = call i32 (...) @getpid()
%6 = mul i32 %4, %5
%7 = call i32 @srand(i32 %6)
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 10
%10 = add nsw i32 %9, 1
store i32 %10, i32* %2
%11 = call i32 (...) @getpid()
%12 = load i32, i32* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
%14 = load i32, i32* %2
%15 = call i32 @sleep(i32 %14)
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"Processo %i criado, ir\C3\A1 dormir por %i \0A\00"
define void @c_sleep() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i64 @time(i32* %1)
%4 = trunc i64 %3 to i32
%5 = call i32 (...) @getpid()
%6 = mul i32 %5, %4
%7 = call i32 @srand(i32 %6)
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 10
%10 = add nsw i32 %9, 1
%11 = call i32 (...) @getpid()
%12 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %10)
%13 = call i32 @sleep(i32 %10)
ret void
}