#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 *, ...);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ wsentry1(int);
int /*<<< orphan*/ wsentry2(float);
void wsmain(int argc, char *argv[]) {
  int i, counter = 5;
  printf("Inside wsmain, %d command line args, argv pointer: %p\n", argc, argv);
  for (i = 0; i < argc; i++) {
    printf("  Arg %d: %s\n", i, argv[i]);
  }
  while (counter > 0) {
    usleep(1000 * 1000);
    printf("Calling entry point 1.\n");
    wsentry1(counter);
    usleep(500 * 1000);
    printf("Calling entry point 2.\n");
    wsentry2((float)counter + 0.5);
    counter--;
  }
  printf("Done calling into WS, exiting\n");
}


x86 assembly (clang, -O0):
<wsmain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5,-0x18(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a9 <wsmain+0x69>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1172 <wsmain+0x32>
jmp    11ae <wsmain+0x6e>
cmpl   $0x0,-0x18(%rbp)
jle    121c <wsmain+0xdc>
mov    $0xf4240,%edi
call   1060 <usleep@plt>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
call   1040 <wsentry1@plt>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2ssl -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdff(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <wsentry2@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    11ae <wsmain+0x6e>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wsmain>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebx
lea    0xeb0(%rip),%rdi
mov    %ebx,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jle    1199 <wsmain+0x49>
mov    %ebx,%r12d
lea    0xecd(%rip),%r14
xor    %ebx,%ebx
mov    (%r15,%rbx,8),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1180 <wsmain+0x30>
mov    $0xf4240,%edi
call   1070 <usleep@plt>
lea    0xecd(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0x5,%edi
call   1050 <wsentry1@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
lea    0xec1(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
movss  0xe23(%rip),%xmm0
call   1060 <wsentry2@plt>
mov    $0xf4240,%edi
call   1070 <usleep@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0x4,%edi
call   1050 <wsentry1@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
movss  0xdec(%rip),%xmm0
call   1060 <wsentry2@plt>
mov    $0xf4240,%edi
call   1070 <usleep@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1050 <wsentry1@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
movss  0xdb5(%rip),%xmm0
call   1060 <wsentry2@plt>
mov    $0xf4240,%edi
call   1070 <usleep@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1050 <wsentry1@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
movss  0xd7e(%rip),%xmm0
call   1060 <wsentry2@plt>
mov    $0xf4240,%edi
call   1070 <usleep@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <wsentry1@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
movss  0xd47(%rip),%xmm0
call   1060 <wsentry2@plt>
lea    0xd84(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [55 x i8] c"Inside wsmain, %d command line args, argv pointer: %p\0A\00"
@.str.1 = [14 x i8] c" Arg %d: %s\0A\00"
@.str.2 = [24 x i8] c"Calling entry point 1.\0A\00"
@.str.3 = [24 x i8] c"Calling entry point 2.\0A\00"
@.str.4 = [31 x i8] c"Done calling into WS, exiting\0A\00"
define void @wsmain(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 5, i32* %6
%7 = load i32, i32* %3
%8 = load i8**, i8*** %4
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %7, i8** %8)
store i32 0, i32* %5
br label %10
10: ; preds = %22, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = load i32, i32* %5
%16 = load i8**, i8*** %4
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %20)
br label %22
22: ; preds = %14
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %10
25: ; preds = %10
br label %26
26: ; preds = %29, %25
%27 = load i32, i32* %6
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %44
29: ; preds = %26
%30 = call i32 @usleep(i32 1000000)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32, i32* %6
%33 = call i32 @wsentry1(i32 %32)
%34 = call i32 @usleep(i32 500000)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%36 = load i32, i32* %6
%37 = sitofp i32 %36 to float
%38 = fpext float %37 to double
%39 = fadd double %38, 5.000000e-01
%40 = fptrunc double %39 to float
%41 = call i32 @wsentry2(float %40)
%42 = load i32, i32* %6
%43 = add nsw i32 %42, -1
store i32 %43, i32* %6
br label %26
44: ; preds = %26
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [55 x i8] c"Inside wsmain, %d command line args, argv pointer: %p\0A\00"
@.str.1 = [14 x i8] c" Arg %d: %s\0A\00"
@str = [30 x i8] c"Done calling into WS, exiting\00"
@str.5 = [23 x i8] c"Calling entry point 1.\00"
@str.6 = [23 x i8] c"Calling entry point 2.\00"
define void @wsmain(i32 %0, i8** %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %0, i8** %1)
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %39
7: ; preds = %39, %2
%8 = tail call i32 @usleep(i32 1000000)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
%10 = tail call i32 @wsentry1(i32 5)
%11 = tail call i32 @usleep(i32 500000)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
%13 = tail call i32 @wsentry2(float 5.500000e+00)
%14 = tail call i32 @usleep(i32 1000000)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
%16 = tail call i32 @wsentry1(i32 4)
%17 = tail call i32 @usleep(i32 500000)
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
%19 = tail call i32 @wsentry2(float 4.500000e+00)
%20 = tail call i32 @usleep(i32 1000000)
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
%22 = tail call i32 @wsentry1(i32 3)
%23 = tail call i32 @usleep(i32 500000)
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
%25 = tail call i32 @wsentry2(float 3.500000e+00)
%26 = tail call i32 @usleep(i32 1000000)
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
%28 = tail call i32 @wsentry1(i32 2)
%29 = tail call i32 @usleep(i32 500000)
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
%31 = tail call i32 @wsentry2(float 2.500000e+00)
%32 = tail call i32 @usleep(i32 1000000)
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
%34 = tail call i32 @wsentry1(i32 1)
%35 = tail call i32 @usleep(i32 500000)
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
%37 = tail call i32 @wsentry2(float 1.500000e+00)
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
ret void
39: ; preds = %5, %39
%40 = phi i64 [ 0, %5 ], [ %45, %39 ]
%41 = getelementptr inbounds i8*, i8** %1, i64 %40
%42 = load i8*, i8** %41
%43 = trunc i64 %40 to i32
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %43, i8* %42)
%45 = add nuw nsw i64 %40, 1
%46 = icmp eq i64 %45, %6
br i1 %46, label %7, label %39
}