#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*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usleep(int);
void f(void) {
  printf("b\n");
  int a = 1;
  fprintf(stderr, "%d\n", a);
  printf("c\n");
  int i = 0;
  while (1) {
    ++i;
    printf("in f (%d)\n", i);
    if (i % 3 == 0) {
      printf("f: switching\n");
    }
    usleep(1000000);
  }
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xea3(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11b6 <f+0x86>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xf4240,%edi
call   1050 <usleep@plt>
jmp    117a <f+0x4a>

x86 assembly (clang, -O2):
<f>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
mov    $0x1,%ebx
mov    $0x1,%edx
call   1050 <fprintf@plt>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r13d
mov    $0xaaaaaaab,%r12d
lea    0xe6f(%rip),%r14
lea    0xe77(%rip),%r15
jmp    11b1 <f+0x71>
xchg   %ax,%ax
mov    $0xf4240,%edi
call   1060 <usleep@plt>
add    $0xffffffff,%r13d
add    $0x1,%ebx
mov    %ebx,%eax
imul   %r12,%rax
shr    $0x21,%rax
lea    (%rax,%rax,2),%ebp
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    %r13d,%ebp
jne    11a0 <f+0x60>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    11a0 <f+0x60>

LLVM IR (-O0):
@.str = [3 x i8] c"b\0A\00"
@stderr = global i32 0
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [3 x i8] c"c\0A\00"
@.str.3 = [11 x i8] c"in f (%d)\0A\00"
@.str.4 = [14 x i8] c"f: switching\0A\00"
define void @f() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
%4 = load i32, i32* @stderr
%5 = load i32, i32* %1
%6 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %8
8: ; preds = %0, %18
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 1
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %2
%14 = srem i32 %13, 3
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %18
18: ; preds = %16, %8
%19 = call i32 @usleep(i32 1000000)
br label %8
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.3 = [11 x i8] c"in f (%d)\0A\00"
@str = [2 x i8] c"b\00"
@str.5 = [2 x i8] c"c\00"
@str.6 = [13 x i8] c"f: switching\00"
define void @f() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%2 = load i32, i32* @stderr
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.5, i64 0, i64 0))
br label %5
5: ; preds = %13, %0
%6 = phi i32 [ 0, %0 ], [ %7, %13 ]
%7 = add nuw nsw i32 %6, 1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = urem i32 %7, 3
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.6, i64 0, i64 0))
br label %13
13: ; preds = %11, %5
%14 = tail call i32 @usleep(i32 1000000)
br label %5
}