#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 /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int a, b, r;
  printf("a = ");
  scanf("%d", &a);
  printf("b = ");
  scanf("%d", &b);
  if (a > b) {
    do {
      r = a % b;
      a = b;
      b = r;
    } while (b);
    printf("NWD = %d\n", a);
  } else {
    do {
      r = b % a;
      b = a;
      a = r;
    } while (a);
    printf("NWD = %d\n", b);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11b2 <main+0x92>
jmp    117c <main+0x5c>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    117c <main+0x5c>
mov    -0x8(%rbp),%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e8 <main+0xc8>
jmp    11b7 <main+0x97>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11b7 <main+0x97>
mov    -0xc(%rbp),%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xecb(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%ecx
cmp    %ecx,%esi
jle    1190 <main+0x70>
xchg   %ax,%ax
mov    %esi,%eax
mov    %ecx,%esi
cltd
idiv   %ecx
mov    %edx,%ecx
test   %edx,%edx
jne    1170 <main+0x50>
mov    %esi,0xc(%rsp)
movl   $0x0,0x8(%rsp)
jmp    11ab <main+0x8b>
nopl   0x0(%rax,%rax,1)
mov    %ecx,%eax
mov    %esi,%ecx
cltd
idiv   %esi
mov    %edx,%esi
test   %edx,%edx
jne    1190 <main+0x70>
mov    %ecx,0x8(%rsp)
movl   $0x0,0xc(%rsp)
mov    %ecx,%esi
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"a = \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"b = \00"
@.str.3 = [10 x i8] c"NWD = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = icmp sgt i32 %9, %10
br i1 %11, label %12, label %18
12: ; preds = %0, %12
%13 = phi i32 [ %15, %12 ], [ %10, %0 ]
%14 = phi i32 [ %13, %12 ], [ %9, %0 ]
%15 = srem i32 %14, %13
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %12
17: ; preds = %12
store i32 %13, i32* %1
store i32 0, i32* %2
br label %24
18: ; preds = %0, %18
%19 = phi i32 [ %21, %18 ], [ %9, %0 ]
%20 = phi i32 [ %19, %18 ], [ %10, %0 ]
%21 = srem i32 %20, %19
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %18
23: ; preds = %18
store i32 %19, i32* %2
store i32 0, i32* %1
br label %24
24: ; preds = %23, %17
%25 = phi i32 [ %19, %23 ], [ %13, %17 ]
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %25)
ret i32 0
}