#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*/ addLeadingZeros(char *, int, int);
int /*<<< orphan*/ addNumbers(char *, char *, int);
int /*<<< orphan*/ printDash(int /*<<< orphan*/, int);
int /*<<< orphan*/ printNumber(char *, int);
int /*<<< orphan*/ printf(char *, char);
int strlen(char *);
int /*<<< orphan*/ subNumbers(char *, char *, int);
void operation(char *op1, char *op2, char op) {
  int l1 = strlen(op1);
  int l2 = strlen(op2);
  int lmax = (l2 > l1) ? l2 : l1;
  addLeadingZeros(op1, l1, lmax);
  addLeadingZeros(op2, l2, lmax);
  printNumber(op1, 1);
  printf("%c", op);
  printNumber(op2, 0);
  printDash(0, lmax + 1);
  switch (op) {
  case '+':
    addNumbers(op1, op2, lmax);
    break;
  case '-':
    subNumbers(op1, op2, lmax);
    break;
  }
}


x86 assembly (clang, -O0):
<operation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11b4 <operation+0x44>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11ba <operation+0x4a>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1030 <addLeadingZeros@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1030 <addLeadingZeros@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1090 <printNumber@plt>
movsbl -0x11(%rbp),%esi
lea    0xe09(%rip),%rdi
call   1080 <printf@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    %esi,-0x2c(%rbp)
call   1090 <printNumber@plt>
mov    -0x2c(%rbp),%edi
mov    -0x20(%rbp),%esi
add    $0x1,%esi
call   1040 <printDash@plt>
movsbl -0x11(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x2b,%eax
je     123e <operation+0xce>
jmp    122d <operation+0xbd>
mov    -0x28(%rbp),%eax
sub    $0x2d,%eax
je     1253 <operation+0xe3>
jmp    1263 <operation+0xf3>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1050 <addNumbers@plt>
jmp    1263 <operation+0xf3>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1070 <subNumbers@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<operation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%r12
call   1060 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
cmp    %ebx,%eax
mov    %ebx,%r13d
cmovg  %eax,%r13d
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r13d,%edx
call   1030 <addLeadingZeros@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
call   1030 <addLeadingZeros@plt>
mov    %r12,%rdi
mov    $0x1,%esi
call   1090 <printNumber@plt>
lea    0xe34(%rip),%rdi
mov    %r15d,%esi
call   1080 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <printNumber@plt>
lea    0x1(%r13),%esi
xor    %edi,%edi
call   1040 <printDash@plt>
cmp    $0x2d,%r15d
je     1211 <operation+0xa1>
cmp    $0x2b,%r15d
jne    122d <operation+0xbd>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <addNumbers@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <subNumbers@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define void @operation(i8* %0, i8* %1, i8 signext %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8 %2, i8* %6
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %7
%12 = load i8*, i8** %5
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = load i32, i32* %7
%16 = icmp sgt i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = load i32, i32* %8
br label %21
19: ; preds = %3
%20 = load i32, i32* %7
br label %21
21: ; preds = %19, %17
%22 = phi i32 [ %18, %17 ], [ %20, %19 ]
store i32 %22, i32* %9
%23 = load i8*, i8** %4
%24 = load i32, i32* %7
%25 = load i32, i32* %9
%26 = call i32 @addLeadingZeros(i8* %23, i32 %24, i32 %25)
%27 = load i8*, i8** %5
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = call i32 @addLeadingZeros(i8* %27, i32 %28, i32 %29)
%31 = load i8*, i8** %4
%32 = call i32 @printNumber(i8* %31, i32 1)
%33 = load i8, i8* %6
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %33)
%35 = load i8*, i8** %5
%36 = call i32 @printNumber(i8* %35, i32 0)
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
%39 = call i32 @printDash(i32 0, i32 %38)
%40 = load i8, i8* %6
%41 = sext i8 %40 to i32
switch i32 %41, label %52 [
i32 43, label %42
i32 45, label %47
]
42: ; preds = %21
%43 = load i8*, i8** %4
%44 = load i8*, i8** %5
%45 = load i32, i32* %9
%46 = call i32 @addNumbers(i8* %43, i8* %44, i32 %45)
br label %52
47: ; preds = %21
%48 = load i8*, i8** %4
%49 = load i8*, i8** %5
%50 = load i32, i32* %9
%51 = call i32 @subNumbers(i8* %48, i8* %49, i32 %50)
br label %52
52: ; preds = %21, %47, %42
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @operation(i8* %0, i8* %1, i8 signext %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @strlen(i8* %1)
%6 = icmp sgt i32 %5, %4
%7 = select i1 %6, i32 %5, i32 %4
%8 = tail call i32 @addLeadingZeros(i8* %0, i32 %4, i32 %7)
%9 = tail call i32 @addLeadingZeros(i8* %1, i32 %5, i32 %7)
%10 = tail call i32 @printNumber(i8* %0, i32 1)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %2)
%12 = tail call i32 @printNumber(i8* %1, i32 0)
%13 = add nsw i32 %7, 1
%14 = tail call i32 @printDash(i32 0, i32 %13)
%15 = sext i8 %2 to i32
switch i32 %15, label %20 [
i32 43, label %16
i32 45, label %18
]
16: ; preds = %3
%17 = tail call i32 @addNumbers(i8* %0, i8* %1, i32 %7)
br label %20
18: ; preds = %3
%19 = tail call i32 @subNumbers(i8* %0, i8* %1, i32 %7)
br label %20
20: ; preds = %3, %18, %16
ret void
}