#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, ...);
void *tables(void *n) {
  int *p = (int *)n;
  printf("tablas %d\n", *p);
  int num, i;
  for (num = 1; num <= *p; num++) {
    for (i = 1; i <= 10; i++)
      printf("%d x %d = %d\n", num, i, num * i);
  }
  return (void *)1;
}


x86 assembly (clang, -O0):
<tables>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jg     119b <tables+0x8b>
movl   $0x1,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jg     1188 <tables+0x78>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
imul   -0x18(%rbp),%ecx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1155 <tables+0x45>
jmp    118d <tables+0x7d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113f <tables+0x2f>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tables>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
mov    (%rdi),%esi
lea    0xed6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,(%rbx)
jle    12dc <tables+0x1cc>
mov    %rbx,%rcx
mov    $0x1,%eax
movl   $0x8,0x10(%rsp)
movl   $0x4,0xc(%rsp)
mov    $0x2,%ebp
movl   $0xa,0x8(%rsp)
movl   $0x9,0x4(%rsp)
movl   $0x7,(%rsp)
mov    $0x6,%r14d
mov    $0x5,%r15d
mov    $0x3,%ebx
mov    %rcx,0x20(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,0x1c(%rsp)
lea    0xe70(%rip),%r13
mov    %r13,%rdi
mov    %rax,%r12
mov    %r12d,%esi
mov    $0x1,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %r12d,%esi
mov    $0x2,%edx
mov    %ebp,0x18(%rsp)
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %r12d,%esi
mov    $0x3,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %r12d,%esi
mov    $0x4,%edx
mov    0xc(%rsp),%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %r12d,%esi
mov    $0x5,%edx
mov    %r15d,0x14(%rsp)
mov    %r15d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %r12d,%esi
mov    $0x6,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %r13,%rbx
mov    %r12d,%esi
mov    $0x7,%edx
mov    (%rsp),%r15d
mov    %r15d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %r12d,%esi
mov    $0x8,%edx
mov    0x10(%rsp),%ebp
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %r12d,%esi
mov    $0x9,%edx
mov    0x4(%rsp),%r13d
mov    %r13d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
mov    $0xa,%edx
mov    0x8(%rsp),%ebx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x20(%rsp),%rcx
lea    0x1(%r12),%eax
add    $0x8,%ebp
mov    %ebp,0x10(%rsp)
addl   $0x4,0xc(%rsp)
mov    0x18(%rsp),%ebp
add    $0x2,%ebp
add    $0xa,%ebx
mov    %ebx,0x8(%rsp)
mov    0x1c(%rsp),%ebx
add    $0x9,%r13d
mov    %r13d,0x4(%rsp)
add    $0x7,%r15d
mov    %r15d,(%rsp)
add    $0x6,%r14d
mov    0x14(%rsp),%r15d
add    $0x5,%r15d
add    $0x3,%ebx
cmp    (%rcx),%r12d
jl     1190 <tables+0x80>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"tablas %d\0A\00"
@.str.1 = [14 x i8] c"%d x %d = %d\0A\00"
define i8* @tables(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = bitcast i8* %6 to i32*
store i32* %7, i32** %3
%8 = load i32*, i32** %3
%9 = load i32, i32* %8
%10 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 1, i32* %4
br label %11
11: ; preds = %31, %1
%12 = load i32, i32* %4
%13 = load i32*, i32** %3
%14 = load i32, i32* %13
%15 = icmp sle i32 %12, %14
br i1 %15, label %16, label %34
16: ; preds = %11
store i32 1, i32* %5
br label %17
17: ; preds = %27, %16
%18 = load i32, i32* %5
%19 = icmp sle i32 %18, 10
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = mul nsw i32 %23, %24
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22, i32 %25)
br label %27
27: ; preds = %20
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %17
30: ; preds = %17
br label %31
31: ; preds = %30
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %11
34: ; preds = %11
ret i8* inttoptr (i64 1 to i8*)
}

LLVM IR (-O2):
@.str = [11 x i8] c"tablas %d\0A\00"
@.str.1 = [14 x i8] c"%d x %d = %d\0A\00"
define i8* @tables(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
%3 = load i32, i32* %2
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 1
br i1 %6, label %31, label %7
7: ; preds = %1, %7
%8 = phi i32 [ %28, %7 ], [ 1, %1 ]
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 1, i32 %8)
%10 = shl nuw nsw i32 %8, 1
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 2, i32 %10)
%12 = mul nuw nsw i32 %8, 3
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 3, i32 %12)
%14 = shl nuw nsw i32 %8, 2
%15 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 4, i32 %14)
%16 = mul nuw nsw i32 %8, 5
%17 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 5, i32 %16)
%18 = mul nuw nsw i32 %8, 6
%19 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 6, i32 %18)
%20 = mul nuw nsw i32 %8, 7
%21 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 7, i32 %20)
%22 = shl nuw nsw i32 %8, 3
%23 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 8, i32 %22)
%24 = mul nuw nsw i32 %8, 9
%25 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 9, i32 %24)
%26 = mul nuw nsw i32 %8, 10
%27 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 10, i32 %26)
%28 = add nuw nsw i32 %8, 1
%29 = load i32, i32* %2
%30 = icmp slt i32 %8, %29
br i1 %30, label %7, label %31
31: ; preds = %7, %1
ret i8* inttoptr (i64 1 to i8*)
}