#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 *, ...);
void runDoWhileLoop(int limit) {
  printf("Do-While loop to %d [ ", limit);
  int i = 0;
  do {
    printf("%d ", i);
    i++;
  } while (i < limit);
  printf("]\n");
}


x86 assembly (clang, -O0):
<runDoWhileLoop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     1133 <runDoWhileLoop+0x23>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runDoWhileLoop>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
lea    0xed3(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%ebp
mov    $0x1,%ebx
cmovge %ebp,%ebx
lea    0xecf(%rip),%r14
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1150 <runDoWhileLoop+0x30>
lea    0xeb1(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Do-While loop to %d [ \00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [3 x i8] c"]\0A\00"
define void @runDoWhileLoop(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 0, i32* %3
br label %6
6: ; preds = %11, %1
%7 = load i32, i32* %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 1
store i32 %10, i32* %3
br label %11
11: ; preds = %6
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %6, label %15
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Do-While loop to %d [ \00"
@.str.1 = [4 x i8] c"%d \00"
@str = [2 x i8] c"]\00"
define void @runDoWhileLoop(i32 %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %0)
%3 = call i32 @llvm.smax.i32(i32 %0, i32 1)
br label %4
4: ; preds = %4, %1
%5 = phi i32 [ 0, %1 ], [ %7, %4 ]
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, %3
br i1 %8, label %9, label %4
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}