#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*/ print_sgr20(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ ptextln(char *);
int /*<<< orphan*/ put_crlf();
int /*<<< orphan*/ set_attr(int /*<<< orphan*/);
void sgr20(void) {
  int k;
  put_crlf();
  ptextln("Test enter/exit attributes 1-9 and 21-29.");
  for (k = 1; k < 10; k++) {
    print_sgr20(k, k + 20);
  }
  print_sgr20(1, 22);
  print_sgr20(2, 22);
  print_sgr20(8, 22);
  printf("\033[0m");
  set_attr(0);
}


x86 assembly (clang, -O0):
<sgr20>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1070 <put_crlf@plt>
lea    0xe9a(%rip),%rdi
call   1030 <ptextln@plt>
movl   $0x1,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    1198 <sgr20+0x48>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
add    $0x14,%esi
call   1040 <print_sgr20@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1172 <sgr20+0x22>
mov    $0x1,%edi
mov    $0x16,%esi
call   1040 <print_sgr20@plt>
mov    $0x2,%edi
mov    $0x16,%esi
call   1040 <print_sgr20@plt>
mov    $0x8,%edi
mov    $0x16,%esi
call   1040 <print_sgr20@plt>
lea    0xe5e(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1060 <set_attr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sgr20>:
push   %rax
xor    %eax,%eax
call   1070 <put_crlf@plt>
lea    0xea1(%rip),%rdi
call   1030 <ptextln@plt>
mov    $0x1,%edi
mov    $0x15,%esi
call   1040 <print_sgr20@plt>
mov    $0x2,%edi
mov    $0x16,%esi
call   1040 <print_sgr20@plt>
mov    $0x3,%edi
mov    $0x17,%esi
call   1040 <print_sgr20@plt>
mov    $0x4,%edi
mov    $0x18,%esi
call   1040 <print_sgr20@plt>
mov    $0x5,%edi
mov    $0x19,%esi
call   1040 <print_sgr20@plt>
mov    $0x6,%edi
mov    $0x1a,%esi
call   1040 <print_sgr20@plt>
mov    $0x7,%edi
mov    $0x1b,%esi
call   1040 <print_sgr20@plt>
mov    $0x8,%edi
mov    $0x1c,%esi
call   1040 <print_sgr20@plt>
mov    $0x9,%edi
mov    $0x1d,%esi
call   1040 <print_sgr20@plt>
mov    $0x1,%edi
mov    $0x16,%esi
call   1040 <print_sgr20@plt>
mov    $0x2,%edi
mov    $0x16,%esi
call   1040 <print_sgr20@plt>
mov    $0x8,%edi
mov    $0x16,%esi
call   1040 <print_sgr20@plt>
lea    0xe0b(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
pop    %rax
jmp    1060 <set_attr@plt>

LLVM IR (-O0):
@.str = [42 x i8] c"Test enter/exit attributes 1-9 and 21-29.\00"
@.str.1 = [5 x i8] c"\1B[0m\00"
define void @sgr20() {
%1 = alloca i32
%2 = call i32 (...) @put_crlf()
%3 = call i32 @ptextln(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %4
4: ; preds = %12, %0
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load i32, i32* %1
%9 = load i32, i32* %1
%10 = add nsw i32 %9, 20
%11 = call i32 @print_sgr20(i32 %8, i32 %10)
br label %12
12: ; preds = %7
%13 = load i32, i32* %1
%14 = add nsw i32 %13, 1
store i32 %14, i32* %1
br label %4
15: ; preds = %4
%16 = call i32 @print_sgr20(i32 1, i32 22)
%17 = call i32 @print_sgr20(i32 2, i32 22)
%18 = call i32 @print_sgr20(i32 8, i32 22)
%19 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @set_attr(i32 0)
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"Test enter/exit attributes 1-9 and 21-29.\00"
@.str.1 = [5 x i8] c"\1B[0m\00"
define void @sgr20() {
%1 = tail call i32 (...) @put_crlf()
%2 = tail call i32 @ptextln(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @print_sgr20(i32 1, i32 21)
%4 = tail call i32 @print_sgr20(i32 2, i32 22)
%5 = tail call i32 @print_sgr20(i32 3, i32 23)
%6 = tail call i32 @print_sgr20(i32 4, i32 24)
%7 = tail call i32 @print_sgr20(i32 5, i32 25)
%8 = tail call i32 @print_sgr20(i32 6, i32 26)
%9 = tail call i32 @print_sgr20(i32 7, i32 27)
%10 = tail call i32 @print_sgr20(i32 8, i32 28)
%11 = tail call i32 @print_sgr20(i32 9, i32 29)
%12 = tail call i32 @print_sgr20(i32 1, i32 22)
%13 = tail call i32 @print_sgr20(i32 2, i32 22)
%14 = tail call i32 @print_sgr20(i32 8, i32 22)
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @set_attr(i32 0)
ret void
}