#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(void) {
  int m;
  int n;
  int r;
  printf("求最大公约数!\n");
  printf("请输入两个数:");
  scanf("%d%d", &m, &n);
  r = m % n;
  while (r != 0) {
    m = n;
    n = r;
    r = m % n;
  }
  printf("最大公约数是%d\n", n);
  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    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     118e <main+0x6e>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
jmp    1169 <main+0x49>
mov    -0xc(%rbp),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xef7(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
mov    (%rsp),%esi
cltd
idiv   %esi
test   %edx,%edx
je     1184 <main+0x54>
nopl   (%rax)
mov    %esi,%ecx
mov    %edx,%esi
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    1170 <main+0x40>
mov    %ecx,0x4(%rsp)
mov    %esi,(%rsp)
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\E6\B1\82\E6\9C\80\E5\A4\A7\E5\85\AC\E7\BA\A6\E6\95\B0!\0A\00"
@.str.1 = [20 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E4\B8\A4\E4\B8\AA\E6\95\B0:\00"
@.str.2 = [5 x i8] c"%d%d\00"
@.str.3 = [22 x i8] c"\E6\9C\80\E5\A4\A7\E5\85\AC\E7\BA\A6\E6\95\B0\E6\98\AF%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 ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3)
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = srem i32 %8, %9
store i32 %10, i32* %4
br label %11
11: ; preds = %14, %0
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i32, i32* %3
store i32 %15, i32* %2
%16 = load i32, i32* %4
store i32 %16, i32* %3
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = srem i32 %17, %18
store i32 %19, i32* %4
br label %11
20: ; preds = %11
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %21)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E4\B8\A4\E4\B8\AA\E6\95\B0:\00"
@.str.2 = [5 x i8] c"%d%d\00"
@.str.3 = [22 x i8] c"\E6\9C\80\E5\A4\A7\E5\85\AC\E7\BA\A6\E6\95\B0\E6\98\AF%d\0A\00"
@str = [20 x i8] c"\E6\B1\82\E6\9C\80\E5\A4\A7\E5\85\AC\E7\BA\A6\E6\95\B0!\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2)
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = srem i32 %8, %9
%11 = icmp eq i32 %10, 0
br i1 %11, label %18, label %12
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 %14, i32* %1
store i32 %13, i32* %2
br label %18
18: ; preds = %17, %0
%19 = phi i32 [ %13, %17 ], [ %9, %0 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %19)
ret i32 0
}