#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);
int rot(int);
int strtol(char *, int /*<<< orphan*/, int);
int main(int argc, char *argv[]) {
  int n = strtol(argv[1], 0, 10);
  while (n != rot(n)) {
    printf("%d -> ", n);
    n = rot(n);
  }
  printf("%d", n);
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <rot@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
je     1197 <main+0x67>
mov    -0x14(%rbp),%esi
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1050 <rot@plt>
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x2d>
mov    -0x14(%rbp),%esi
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <rot@plt>
cmp    %eax,%ebx
je     117e <main+0x4e>
lea    0xea8(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%edi
call   1050 <rot@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <rot@plt>
cmp    %eax,%ebx
jne    1160 <main+0x30>
lea    0xe82(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d -> \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = call i32 @strtol(i8* %9, i32 0, i32 10)
store i32 %10, i32* %6
br label %11
11: ; preds = %16, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %6
%14 = call i32 @rot(i32 %13)
%15 = icmp ne i32 %12, %14
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32, i32* %6
%18 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %6
%20 = call i32 @rot(i32 %19)
store i32 %20, i32* %6
br label %11
21: ; preds = %11
%22 = load i32, i32* %6
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d -> \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @strtol(i8* %4, i32 0, i32 10)
%6 = tail call i32 @rot(i32 %5)
%7 = icmp eq i32 %5, %6
br i1 %7, label %14, label %8
8: ; preds = %2, %8
%9 = phi i32 [ %11, %8 ], [ %5, %2 ]
%10 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = tail call i32 @rot(i32 %9)
%12 = tail call i32 @rot(i32 %11)
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %8
14: ; preds = %8, %2
%15 = phi i32 [ %5, %2 ], [ %11, %8 ]
%16 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %15)
ret i32 0
}