#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 cut_into_small_pieces(int, int *);
int get_biggest_knife(int, int);
int /*<<< orphan*/ print_optional_plus_symbol();
int /*<<< orphan*/ printf(char *, int);
int divide_into_numbers_with_same_digit_and_print(int watermelon, int knife) {
  printf("%d = ", watermelon);
  int biggest_knife = get_biggest_knife(watermelon, knife);
  int rest_wm = watermelon;
  while (rest_wm > 0) {
    print_optional_plus_symbol();
    rest_wm = cut_into_small_pieces(rest_wm, &biggest_knife);
  }
  return 0;
}


x86 assembly (clang, -O0):
<divide_into_numbers_with_same_digit_and_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <get_biggest_knife@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    1196 <divide_into_numbers_with_same_digit_and_print+0x56>
mov    $0x0,%al
call   1060 <print_optional_plus_symbol@plt>
mov    -0x10(%rbp),%edi
lea    -0xc(%rbp),%rsi
call   1050 <cut_into_small_pieces@plt>
mov    %eax,-0x10(%rbp)
jmp    1171 <divide_into_numbers_with_same_digit_and_print+0x31>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<divide_into_numbers_with_same_digit_and_print>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
lea    0xead(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <get_biggest_knife@plt>
mov    %eax,0xc(%rsp)
test   %ebx,%ebx
jle    1187 <divide_into_numbers_with_same_digit_and_print+0x47>
lea    0xc(%rsp),%r14
xor    %eax,%eax
call   1060 <print_optional_plus_symbol@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <cut_into_small_pieces@plt>
mov    %eax,%ebx
test   %eax,%eax
jg     1170 <divide_into_numbers_with_same_digit_and_print+0x30>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d = \00"
define i32 @divide_into_numbers_with_same_digit_and_print(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
%7 = load i32, i32* %3
%8 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = call i32 @get_biggest_knife(i32 %9, i32 %10)
store i32 %11, i32* %5
%12 = load i32, i32* %3
store i32 %12, i32* %6
br label %13
13: ; preds = %16, %2
%14 = load i32, i32* %6
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = call i32 (...) @print_optional_plus_symbol()
%18 = load i32, i32* %6
%19 = call i32 @cut_into_small_pieces(i32 %18, i32* %5)
store i32 %19, i32* %6
br label %13
20: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d = \00"
define i32 @divide_into_numbers_with_same_digit_and_print(i32 %0, i32 %1) {
%3 = alloca i32
%4 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = bitcast i32* %3 to i8*
%6 = tail call i32 @get_biggest_knife(i32 %0, i32 %1)
store i32 %6, i32* %3
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %13
8: ; preds = %2, %8
%9 = phi i32 [ %11, %8 ], [ %0, %2 ]
%10 = call i32 (...) @print_optional_plus_symbol()
%11 = call i32 @cut_into_small_pieces(i32 %9, i32* %3)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %8, label %13
13: ; preds = %8, %2
ret i32 0
}