#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 *);
int main() {
  int a, b;
  printf("Podaj dwie liczby: ");
  scanf("%d %d", &a, &b);
  while (a != b) {
    if (a > b)
      a -= b;
    else
      b -= a;
  }
  printf("NWD wynosi: %d\n", a);
}


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    0xed0(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1189 <main+0x69>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1179 <main+0x59>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    1184 <main+0x64>
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    1151 <main+0x31>
mov    -0x8(%rbp),%esi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
mov    (%rsp),%esi
cmp    %esi,%eax
jne    116b <main+0x4b>
mov    %eax,%esi
jmp    117b <main+0x5b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
sub    %eax,%esi
mov    %esi,(%rsp)
mov    %eax,%ecx
cmp    %esi,%ecx
je     117b <main+0x5b>
mov    %eax,%ecx
sub    %esi,%ecx
jle    1160 <main+0x40>
mov    %ecx,0x4(%rsp)
mov    %ecx,%eax
cmp    %esi,%ecx
jne    116b <main+0x4b>
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [20 x i8] c"Podaj dwie liczby: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [16 x i8] c"NWD wynosi: %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 ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = icmp eq i32 %7, %8
br i1 %9, label %22, label %10
10: ; preds = %0, %18
%11 = phi i32 [ %20, %18 ], [ %7, %0 ]
%12 = phi i32 [ %19, %18 ], [ %8, %0 ]
%13 = icmp sgt i32 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = sub nsw i32 %11, %12
store i32 %15, i32* %1
br label %18
16: ; preds = %10
%17 = sub nsw i32 %12, %11
store i32 %17, i32* %2
br label %18
18: ; preds = %16, %14
%19 = phi i32 [ %17, %16 ], [ %12, %14 ]
%20 = phi i32 [ %11, %16 ], [ %15, %14 ]
%21 = icmp eq i32 %20, %19
br i1 %21, label %22, label %10
22: ; preds = %18, %0
%23 = phi i32 [ %7, %0 ], [ %19, %18 ]
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %23)
ret i32 0
}