#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 gcd_info(int u, int v) {
  int instructions = 0;
  int t;
  while (u > 0) {
    if (u < v) {
      t = u;
      u = v;
      v = t;
      instructions += 3;
      printf("v: %d\n", v);
    }
    u = u - v;
    instructions += 3;
    printf("u: %d\n", u);
  }
  printf("instructions: %d\n", instructions + 1);
  return v;
}


x86 assembly (clang, -O0):
<gcd_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    118b <gcd_info+0x7b>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1165 <gcd_info+0x55>
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
jmp    1125 <gcd_info+0x15>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gcd_info>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
test   %edi,%edi
jle    1179 <gcd_info+0x69>
mov    %edi,%ebp
xor    %ebx,%ebx
lea    0xeda(%rip),%r15
jmp    1163 <gcd_info+0x53>
nop
add    $0x3,%ebx
lea    0xec6(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %ebp,%r12d
mov    %ebx,%r13d
mov    %r14d,%ebp
mov    %r12d,%r14d
lea    0x3(%r13),%ebx
mov    %ebp,%esi
sub    %r12d,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
sub    %r12d,%ebp
jle    1170 <gcd_info+0x60>
cmp    %r14d,%ebp
jl     1130 <gcd_info+0x20>
mov    %r14d,%r12d
mov    %ebx,%r13d
jmp    114d <gcd_info+0x3d>
add    $0x4,%r13d
mov    %r12d,%r14d
jmp    117f <gcd_info+0x6f>
mov    $0x1,%r13d
lea    0xe88(%rip),%rdi
mov    %r13d,%esi
call   1030 <printf@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"v: %d\0A\00"
@.str.1 = [7 x i8] c"u: %d\0A\00"
@.str.2 = [18 x i8] c"instructions: %d\0A\00"
define i32 @gcd_info(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %22, %2
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %30
10: ; preds = %7
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = load i32, i32* %3
store i32 %15, i32* %6
%16 = load i32, i32* %4
store i32 %16, i32* %3
%17 = load i32, i32* %6
store i32 %17, i32* %4
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 3
store i32 %19, i32* %5
%20 = load i32, i32* %4
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %14, %10
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = sub nsw i32 %23, %24
store i32 %25, i32* %3
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 3
store i32 %27, i32* %5
%28 = load i32, i32* %3
%29 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %7
30: ; preds = %7
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
%33 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
@.str = [7 x i8] c"v: %d\0A\00"
@.str.1 = [7 x i8] c"u: %d\0A\00"
@.str.2 = [18 x i8] c"instructions: %d\0A\00"
define i32 @gcd_info(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %22
4: ; preds = %2, %12
%5 = phi i32 [ %16, %12 ], [ %0, %2 ]
%6 = phi i32 [ %17, %12 ], [ 0, %2 ]
%7 = phi i32 [ %13, %12 ], [ %1, %2 ]
%8 = icmp slt i32 %5, %7
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = add nsw i32 %6, 3
%11 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %12
12: ; preds = %9, %4
%13 = phi i32 [ %5, %9 ], [ %7, %4 ]
%14 = phi i32 [ %10, %9 ], [ %6, %4 ]
%15 = phi i32 [ %7, %9 ], [ %5, %4 ]
%16 = sub nsw i32 %15, %13
%17 = add nsw i32 %14, 3
%18 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%19 = icmp sgt i32 %16, 0
br i1 %19, label %4, label %20
20: ; preds = %12
%21 = add i32 %14, 4
br label %22
22: ; preds = %20, %2
%23 = phi i32 [ %1, %2 ], [ %13, %20 ]
%24 = phi i32 [ 1, %2 ], [ %21, %20 ]
%25 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %24)
ret i32 %23
}