#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 main() {
  int x, y;
  int h = 0;
  int l = 0;
  char caractere;
  char choice;
  int end = 0;
  while (end == 0) {
    printf("Insira Largura:");
    scanf("%d", &l);
    printf("Insira Altura:");
    scanf("%d", &h);
    printf("\nInsira o Caractere que será impresso:");
    scanf(" %c", &caractere);
    printf("Olá, meu nome é André e o seu retângulo ficou assim:\n");
    for (x = 0; x < h; x++) {
      for (y = 0; y < l; y++) {
        if (x == 0 || x == h - 1 || y == 0 || y == l - 1) {
          printf("%c", caractere);
        } else {
          printf(" ");
        }
      }
      printf("\n");
    }
    printf("Deseja continuar (S/n)?");
    scanf(" %c", &choice);
    if (choice == 'n') {
      end = 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    12a5 <main+0x185>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea7(%rip),%rdi
lea    -0x15(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    126c <main+0x14c>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1250 <main+0x130>
cmpl   $0x0,-0x8(%rbp)
je     1218 <main+0xf8>
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1218 <main+0xf8>
cmpl   $0x0,-0xc(%rbp)
je     1218 <main+0xf8>
mov    -0xc(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    122f <main+0x10f>
movsbl -0x15(%rbp),%esi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123d <main+0x11d>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1242 <main+0x122>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d6 <main+0xb6>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c3 <main+0xa3>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdc9(%rip),%rdi
lea    -0x16(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x16(%rbp),%eax
cmp    $0x6e,%eax
jne    12a0 <main+0x180>
movl   $0x1,-0x1c(%rbp)
jmp    1144 <main+0x24>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x10(%rsp)
movl   $0x0,0x14(%rsp)
lea    0xeab(%rip),%rbx
lea    0xede(%rip),%r14
lea    0xedb(%rip),%r13
lea    0xe(%rsp),%rbp
jmp    11a2 <main+0x62>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpb   $0x6e,0xe(%rsp)
je     128c <main+0x14c>
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe4d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe3f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
lea    0xf(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe66(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0x10(%rsp)
jle    1180 <main+0x40>
xor    %r15d,%r15d
jmp    1239 <main+0xf9>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15d
cmp    0x10(%rsp),%r15d
jge    1180 <main+0x40>
mov    0x14(%rsp),%eax
test   %eax,%eax
jle    1220 <main+0xe0>
xor    %r12d,%r12d
jmp    1267 <main+0x127>
cs nopw 0x0(%rax,%rax,1)
movsbl 0xf(%rsp),%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
mov    0x14(%rsp),%eax
cmp    %eax,%r12d
jge    1220 <main+0xe0>
test   %r15d,%r15d
je     1250 <main+0x110>
mov    0x10(%rsp),%ecx
add    $0xffffffff,%ecx
cmp    %ecx,%r15d
je     1250 <main+0x110>
test   %r12d,%r12d
je     1250 <main+0x110>
add    $0xffffffff,%eax
mov    $0x20,%edi
cmp    %eax,%r12d
jne    1255 <main+0x115>
jmp    1250 <main+0x110>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Insira Largura:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"Insira Altura:\00"
@.str.3 = [40 x i8] c"\0AInsira o Caractere que ser\C3\A1 impresso:\00"
@.str.4 = [4 x i8] c" %c\00"
@.str.5 = [58 x i8] c"Ol\C3\A1, meu nome \C3\A9 Andr\C3\A9 e o seu ret\C3\A2ngulo ficou assim:\0A\00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [2 x i8] c" \00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [24 x i8] c"Deseja continuar (S/n)?\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %8
br label %9
9: ; preds = %67, %0
%10 = load i32, i32* %8
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %68
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %2
br label %20
20: ; preds = %57, %12
%21 = load i32, i32* %2
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %60
24: ; preds = %20
store i32 0, i32* %3
br label %25
25: ; preds = %52, %24
%26 = load i32, i32* %3
%27 = load i32, i32* %5
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %55
29: ; preds = %25
%30 = load i32, i32* %2
%31 = icmp eq i32 %30, 0
br i1 %31, label %45, label %32
32: ; preds = %29
%33 = load i32, i32* %2
%34 = load i32, i32* %4
%35 = sub nsw i32 %34, 1
%36 = icmp eq i32 %33, %35
br i1 %36, label %45, label %37
37: ; preds = %32
%38 = load i32, i32* %3
%39 = icmp eq i32 %38, 0
br i1 %39, label %45, label %40
40: ; preds = %37
%41 = load i32, i32* %3
%42 = load i32, i32* %5
%43 = sub nsw i32 %42, 1
%44 = icmp eq i32 %41, %43
br i1 %44, label %45, label %49
45: ; preds = %40, %37, %32, %29
%46 = load i8, i8* %6
%47 = sext i8 %46 to i32
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %47)
br label %51
49: ; preds = %40
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %51
51: ; preds = %49, %45
br label %52
52: ; preds = %51
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
store i32 %54, i32* %3
br label %25
55: ; preds = %25
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %57
57: ; preds = %55
%58 = load i32, i32* %2
%59 = add nsw i32 %58, 1
store i32 %59, i32* %2
br label %20
60: ; preds = %20
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
%62 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%63 = load i8, i8* %7
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 110
br i1 %65, label %66, label %67
66: ; preds = %60
store i32 1, i32* %8
br label %67
67: ; preds = %66, %60
br label %9
68: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"Insira Largura:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"Insira Altura:\00"
@.str.3 = [40 x i8] c"\0AInsira o Caractere que ser\C3\A1 impresso:\00"
@.str.4 = [4 x i8] c" %c\00"
@.str.9 = [24 x i8] c"Deseja continuar (S/n)?\00"
@str = [57 x i8] c"Ol\C3\A1, meu nome \C3\A9 Andr\C3\A9 e o seu ret\C3\A2ngulo ficou assim:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8
%5 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%6 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %7
7: ; preds = %0, %49
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %49
17: ; preds = %7, %44
%18 = phi i32 [ %46, %44 ], [ 0, %7 ]
%19 = load i32, i32* %2
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %44
21: ; preds = %17
%22 = icmp eq i32 %18, 0
br label %23
23: ; preds = %21, %38
%24 = phi i32 [ %19, %21 ], [ %42, %38 ]
%25 = phi i32 [ 0, %21 ], [ %41, %38 ]
br i1 %22, label %35, label %26
26: ; preds = %23
%27 = load i32, i32* %1
%28 = add nsw i32 %27, -1
%29 = icmp eq i32 %18, %28
%30 = icmp eq i32 %25, 0
%31 = select i1 %29, i1 true, i1 %30
%32 = add nsw i32 %24, -1
%33 = icmp eq i32 %25, %32
%34 = select i1 %31, i1 true, i1 %33
br i1 %34, label %35, label %38
35: ; preds = %26, %23
%36 = load i8, i8* %3
%37 = sext i8 %36 to i32
br label %38
38: ; preds = %26, %35
%39 = phi i32 [ %37, %35 ], [ 32, %26 ]
%40 = call i32 @putchar(i32 %39)
%41 = add nuw nsw i32 %25, 1
%42 = load i32, i32* %2
%43 = icmp slt i32 %41, %42
br i1 %43, label %23, label %44
44: ; preds = %38, %17
%45 = call i32 @putchar(i32 10)
%46 = add nuw nsw i32 %18, 1
%47 = load i32, i32* %1
%48 = icmp slt i32 %46, %47
br i1 %48, label %17, label %49
49: ; preds = %44, %7
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
%51 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%52 = load i8, i8* %4
%53 = icmp eq i8 %52, 110
br i1 %53, label %54, label %7
54: ; preds = %49
ret i32 0
}