#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 CHAR_MAX;
int /*<<< orphan*/ printf(char *, char);
int main(void) {
  char result;
  result = CHAR_MAX + 10 - 20;
  printf("result = %d\n", result);
  result = (CHAR_MAX + 10) - 20;
  printf("result = %d\n", result);
  result = CHAR_MAX + (10 - 20);
  printf("result = %d\n", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ec2(%rip),%rax
mov    (%rax),%eax
add    $0xa,%eax
sub    $0x14,%eax
mov    %al,-0x5(%rbp)
lea    0xec8(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <printf@plt>
mov    0x2ea0(%rip),%rax
mov    (%rax),%eax
add    $0xa,%eax
sub    $0x14,%eax
mov    %al,-0x5(%rbp)
lea    0xea6(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <printf@plt>
mov    0x2e7e(%rip),%rax
mov    (%rax),%eax
add    $0xfffffff6,%eax
mov    %al,-0x5(%rbp)
lea    0xe87(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2ecd(%rip),%r14
mov    (%r14),%al
add    $0xf6,%al
movsbl %al,%esi
lea    0xed6(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%r14),%al
add    $0xf6,%al
movsbl %al,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%r14),%al
add    $0xf6,%al
movsbl %al,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@CHAR_MAX = global i32 0
@.str = [13 x i8] c"result = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = load i32, i32* @CHAR_MAX
%4 = add nsw i32 %3, 10
%5 = sub nsw i32 %4, 20
%6 = trunc i32 %5 to i8
store i8 %6, i8* %2
%7 = load i8, i8* %2
%8 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 signext %7)
%9 = load i32, i32* @CHAR_MAX
%10 = add nsw i32 %9, 10
%11 = sub nsw i32 %10, 20
%12 = trunc i32 %11 to i8
store i8 %12, i8* %2
%13 = load i8, i8* %2
%14 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 signext %13)
%15 = load i32, i32* @CHAR_MAX
%16 = add nsw i32 %15, -10
%17 = trunc i32 %16 to i8
store i8 %17, i8* %2
%18 = load i8, i8* %2
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 signext %18)
ret i32 0
}

LLVM IR (-O2):
@CHAR_MAX = global i32 0
@.str = [13 x i8] c"result = %d\0A\00"
define i32 @main() {
%1 = load i32, i32* @CHAR_MAX
%2 = trunc i32 %1 to i8
%3 = add i8 %2, -10
%4 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 signext %3)
%5 = load i32, i32* @CHAR_MAX
%6 = trunc i32 %5 to i8
%7 = add i8 %6, -10
%8 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 signext %7)
%9 = load i32, i32* @CHAR_MAX
%10 = trunc i32 %9 to i8
%11 = add i8 %10, -10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 signext %11)
ret i32 0
}