#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*/ sprintf(char *, char *, int);
int /*<<< orphan*/ writefile(char *);
int main(int argc, char **argv) {
  int i = 0;
  char name[9];
  for (i = 0; i < 100; i++) {
    if (i / 10 * 10 == i) {
      sprintf(name, "file%i.txt", i);
      writefile(name);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    1194 <main+0x74>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
imul   $0xa,%eax,%eax
cmp    -0x14(%rbp),%eax
jne    1181 <main+0x61>
lea    -0x1d(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe8d(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x1d(%rbp),%rdi
call   1030 <writefile@plt>
jmp    1186 <main+0x66>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <main+0x24>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
lea    0xece(%rip),%r14
lea    0x7(%rsp),%r15
jmp    1148 <main+0x28>
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    $0x64,%ebx
je     1177 <main+0x57>
movzbl %bl,%eax
imul   $0xcd,%eax,%ecx
shr    $0xa,%ecx
and    $0xfffffffe,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
add    %cl,%al
jne    1140 <main+0x20>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <sprintf@plt>
mov    %r15,%rdi
call   1030 <writefile@plt>
jmp    1140 <main+0x20>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"file%i.txt\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [9 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %6
br label %8
8: ; preds = %24, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 100
br i1 %10, label %11, label %27
11: ; preds = %8
%12 = load i32, i32* %6
%13 = sdiv i32 %12, 10
%14 = mul nsw i32 %13, 10
%15 = load i32, i32* %6
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%19 = load i32, i32* %6
%20 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%22 = call i32 @writefile(i8* %21)
br label %23
23: ; preds = %17, %11
br label %24
24: ; preds = %23
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %8
27: ; preds = %8
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [11 x i8] c"file%i.txt\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [9 x i8]
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %2, %13
%6 = phi i32 [ 0, %2 ], [ %14, %13 ]
%7 = trunc i32 %6 to i8
%8 = urem i8 %7, 10
%9 = icmp eq i8 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %6)
%12 = call i32 @writefile(i8* %4)
br label %13
13: ; preds = %5, %10
%14 = add nuw nsw i32 %6, 1
%15 = icmp eq i32 %14, 100
br i1 %15, label %16, label %5
16: ; preds = %13
ret i32 0
}