#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, int, ...);
int main() {
  int a = 25, b = 8;
  int r0 = a;
  int r1 = b;
  int gcd_ab;
  while (1) {
    int q1 = r0 / r1;
    int r2 = r0 - q1 * r1;
    printf("%d=%d-%d*%d\n", r2, r0, q1, r1);
    r0 = r1;
    r1 = r2;
    if (r2 == 0) {
      gcd_ab = r0;
      break;
    }
  }
  printf("gcd(%d,%d)=%d\n", a, b, gcd_ab);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x19,-0x8(%rbp)
movl   $0x8,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   -0x14(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    118e <main+0x7e>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1193 <main+0x83>
jmp    1139 <main+0x29>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x19,%ebx
mov    $0x8,%ebp
lea    0xedb(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%ecx
mov    %ebp,%ebx
mov    %ecx,%eax
cltd
idiv   %ebp
mov    %edx,%ebp
mov    %r14,%rdi
mov    %edx,%esi
mov    %ecx,%edx
mov    %eax,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebp,%ebp
jne    1130 <main+0x20>
lea    0xeb4(%rip),%rdi
mov    $0x19,%esi
mov    $0x8,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"%d=%d-%d*%d\0A\00"
@.str.1 = [15 x i8] c"gcd(%d,%d)=%d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 8, %0 ], [ %6, %1 ]
%3 = phi i32 [ 25, %0 ], [ %2, %1 ]
%4 = sdiv i32 %3, %2
%5 = mul nsw i32 %4, %2
%6 = srem i32 %3, %2
%7 = tail call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %3, i32 %4, i32 %2)
%8 = icmp eq i32 %6, 0
br i1 %8, label %9, label %1
9: ; preds = %1
%10 = tail call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 25, i32 8, i32 %2)
ret i32 0
}