#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 simulate(int no, char *locker) {
  int i, j, k, l;
  printf("locker #\t\n");
  for (i = 1; i <= no; i++) {
    printf("\t%d", i);
  }
  printf("\n==================================================================="
         "======================\n");
  for (i = 1; i <= no; i++) {
    printf("%dth std   ", i);
    for (j = 1; j <= no; j++) {
      if (i == 1) {
        for (k = 1; k <= no; k++) {
          locker[k] = 'o';
          printf("%c\t", locker[k]);
        }
        printf("\n");
        break;
      }
      if (j % i == 0) {
        if (locker[j] == 'o') {
          locker[j] = 'c';
        } else
          locker[j] = 'o';
      }
      printf("%c\t", locker[j]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<simulate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     115f <simulate+0x4f>
mov    -0x14(%rbp),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1134 <simulate+0x24>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1293 <simulate+0x183>
mov    -0x14(%rbp),%esi
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1277 <simulate+0x167>
cmpl   $0x1,-0x14(%rbp)
jne    1208 <simulate+0xf8>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11f5 <simulate+0xe5>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x6f,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b5 <simulate+0xa5>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1277 <simulate+0x167>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    124f <simulate+0x13f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x6f,%eax
jne    123e <simulate+0x12e>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x63,(%rax,%rcx,1)
jmp    124a <simulate+0x13a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x6f,(%rax,%rcx,1)
jmp    124f <simulate+0x13f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1198 <simulate+0x88>
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1174 <simulate+0x64>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simulate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r14d
lea    0xecc(%rip),%rdi
call   1040 <puts@plt>
test   %r14d,%r14d
jle    1278 <simulate+0x148>
mov    %r14,(%rsp)
neg    %r14d
mov    $0x1,%ebp
lea    0xe97(%rip),%r15
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    (%r14,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    1170 <simulate+0x40>
lea    0xe88(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%rax
test   %eax,%eax
jle    1269 <simulate+0x139>
lea    0x1(%rax),%r15d
mov    $0x1,%r12d
lea    0xe58(%rip),%r13
mov    $0x63,%r14d
jmp    11dc <simulate+0xac>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r12),%eax
cmp    (%rsp),%r12d
mov    %eax,%r12d
je     1269 <simulate+0x139>
lea    0xe21(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebp
cmp    $0x1,%r12d
jne    124a <simulate+0x11a>
nopl   0x0(%rax,%rax,1)
movb   $0x6f,(%rbx,%rbp,1)
mov    %r13,%rdi
mov    $0x6f,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1200 <simulate+0xd0>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11c0 <simulate+0x90>
nopl   0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
je     11c0 <simulate+0x90>
mov    %ebp,%eax
xor    %edx,%edx
div    %r12d
movzbl (%rbx,%rbp,1),%eax
test   %edx,%edx
jne    1230 <simulate+0x100>
cmp    $0x6f,%al
mov    $0x6f,%eax
cmove  %r14d,%eax
mov    %al,(%rbx,%rbp,1)
jmp    1230 <simulate+0x100>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd9f(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"locker #\09\0A\00"
@.str.1 = [4 x i8] c"\09%d\00"
@.str.2 = [92 x i8] c"\0A=========================================================================================\0A\00"
@.str.3 = [12 x i8] c"%dth std \00"
@.str.4 = [4 x i8] c"%c\09\00"
@.str.5 = [2 x i8] c"\0A\00"
define void @simulate(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %10
10: ; preds = %17, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %3
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = load i32, i32* %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %10
20: ; preds = %10
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %5
br label %22
22: ; preds = %95, %20
%23 = load i32, i32* %5
%24 = load i32, i32* %3
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %98
26: ; preds = %22
%27 = load i32, i32* %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %27)
store i32 1, i32* %6
br label %29
29: ; preds = %90, %26
%30 = load i32, i32* %6
%31 = load i32, i32* %3
%32 = icmp sle i32 %30, %31
br i1 %32, label %33, label %93
33: ; preds = %29
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %58
36: ; preds = %33
store i32 1, i32* %7
br label %37
37: ; preds = %53, %36
%38 = load i32, i32* %7
%39 = load i32, i32* %3
%40 = icmp sle i32 %38, %39
br i1 %40, label %41, label %56
41: ; preds = %37
%42 = load i8*, i8** %4
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
store i8 111, i8* %45
%46 = load i8*, i8** %4
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %41
%54 = load i32, i32* %7
%55 = add nsw i32 %54, 1
store i32 %55, i32* %7
br label %37
56: ; preds = %37
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %93
58: ; preds = %33
%59 = load i32, i32* %6
%60 = load i32, i32* %5
%61 = srem i32 %59, %60
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %82
63: ; preds = %58
%64 = load i8*, i8** %4
%65 = load i32, i32* %6
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %64, i64 %66
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 111
br i1 %70, label %71, label %76
71: ; preds = %63
%72 = load i8*, i8** %4
%73 = load i32, i32* %6
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %72, i64 %74
store i8 99, i8* %75
br label %81
76: ; preds = %63
%77 = load i8*, i8** %4
%78 = load i32, i32* %6
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8, i8* %77, i64 %79
store i8 111, i8* %80
br label %81
81: ; preds = %76, %71
br label %82
82: ; preds = %81, %58
%83 = load i8*, i8** %4
%84 = load i32, i32* %6
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %83, i64 %85
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %88)
br label %90
90: ; preds = %82
%91 = load i32, i32* %6
%92 = add nsw i32 %91, 1
store i32 %92, i32* %6
br label %29
93: ; preds = %56, %29
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %95
95: ; preds = %93
%96 = load i32, i32* %5
%97 = add nsw i32 %96, 1
store i32 %97, i32* %5
br label %22
98: ; preds = %22
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"\09%d\00"
@.str.3 = [12 x i8] c"%dth std \00"
@.str.4 = [4 x i8] c"%c\09\00"
@str = [10 x i8] c"locker #\09\00"
@str.6 = [91 x i8] c"\0A=========================================================================================\00"
define void @simulate(i32 %0, i8* nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%4 = icmp slt i32 %0, 1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @str.6, i64 0, i64 0))
br label %50
7: ; preds = %2, %7
%8 = phi i32 [ %10, %7 ], [ 1, %2 ]
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = add nuw i32 %8, 1
%11 = icmp eq i32 %8, %0
br i1 %11, label %12, label %7
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @str.6, i64 0, i64 0))
br i1 %4, label %50, label %14
14: ; preds = %12
%15 = add nuw i32 %0, 1
%16 = zext i32 %15 to i64
%17 = zext i32 %15 to i64
br label %18
18: ; preds = %46, %14
%19 = phi i32 [ 1, %14 ], [ %48, %46 ]
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = icmp eq i32 %19, 1
br i1 %21, label %29, label %22
22: ; preds = %18, %40
%23 = phi i64 [ %44, %40 ], [ 1, %18 ]
%24 = trunc i64 %23 to i32
%25 = urem i32 %24, %19
%26 = icmp eq i32 %25, 0
%27 = getelementptr inbounds i8, i8* %1, i64 %23
%28 = load i8, i8* %27
br i1 %26, label %37, label %40
29: ; preds = %18, %29
%30 = phi i64 [ %33, %29 ], [ 1, %18 ]
%31 = getelementptr inbounds i8, i8* %1, i64 %30
store i8 111, i8* %31
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 111)
%33 = add nuw nsw i64 %30, 1
%34 = icmp eq i64 %33, %17
br i1 %34, label %35, label %29
35: ; preds = %29
%36 = tail call i32 @putchar(i32 10)
br label %46
37: ; preds = %22
%38 = icmp eq i8 %28, 111
%39 = select i1 %38, i8 99, i8 111
store i8 %39, i8* %27
br label %40
40: ; preds = %37, %22
%41 = phi i8 [ %28, %22 ], [ %39, %37 ]
%42 = sext i8 %41 to i32
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = add nuw nsw i64 %23, 1
%45 = icmp eq i64 %44, %16
br i1 %45, label %46, label %22
46: ; preds = %40, %35
%47 = tail call i32 @putchar(i32 10)
%48 = add nuw i32 %19, 1
%49 = icmp eq i32 %19, %0
br i1 %49, label %50, label %18
50: ; preds = %46, %5, %12
ret void
}