void main(argc, argv) int argc;
const char *argv[];
{
  unsigned count, ii;
  (void)sscanf(argv[1], "%u", &count);
  printf("%u cascaded NMOS inverters\n", count);
  for (ii = 1; ii <= count; ii++) {
    int in = ii * 2 - 1;
    int out = ii * 2 + 1;
    int pwr = ii * 2;
    printf("vd%u %u 0 5\n", ii, pwr);
    printf("md%u  %u %u %u %u  modeld w=10u l=2u\n", ii, out, in, 0, 0);
    printf("ml%u  %u %u %u %u  modell w=2u l=2u\n", ii, pwr, pwr, out, 0);
  }
  printf("vin 1 0 .8\n");
  printf(".MODEL MODELD NMOS (level=2 KP=28U VTO=0.7 LAMBDA=0.01 GAMMA=0.9 "
         "PHI=0.5)\n");
  printf(".MODEL MODELL NMOS (level=2 KP=28U VTO=0.7 LAMBDA=0.01 GAMMA=0.9 "
         "PHI=0.5)\n");
  printf(".PRINT OP iter(0) V(nodes)\n");
  printf(".op\n");
  printf(".options acct\n");
  printf(".end\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xec2(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    -0x14(%rbp),%esi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
ja     11eb <main+0xcb>
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe7a(%rip),%rdi
xor    %r9d,%r9d
mov    %r9d,%r8d
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xe7f(%rip),%rdi
xor    %r9d,%r9d
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1161 <main+0x41>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
lea    0xeba(%rip),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
mov    0x4(%rsp),%esi
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x4(%rsp)
je     11e6 <main+0xb6>
mov    $0x1,%ebp
mov    $0x3,%ebx
lea    0xeb0(%rip),%r15
lea    0xecf(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x1(%rbx),%r13d
lea    -0x2(%rbx),%r14d
lea    0xe80(%rip),%rdi
mov    %ebp,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %r13d,%ecx
mov    %ebx,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
add    $0x2,%ebx
cmp    0x4(%rsp),%ebp
jbe    1190 <main+0x60>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
lea    0xf05(%rip),%rdi
call   1030 <puts@plt>
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0c(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0e(%rip),%rdi
call   1030 <puts@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"%u\00"
@.str.1 = [28 x i8] c"%u cascaded NMOS inverters\0A\00"
@.str.2 = [13 x i8] c"vd%u %u 0 5\0A\00"
@.str.3 = [38 x i8] c"md%u %u %u %u %u modeld w=10u l=2u\0A\00"
@.str.4 = [37 x i8] c"ml%u %u %u %u %u modell w=2u l=2u\0A\00"
@.str.5 = [12 x i8] c"vin 1 0 .8\0A\00"
@.str.6 = [75 x i8] c".MODEL MODELD NMOS (level=2 KP=28U VTO=0.7 LAMBDA=0.01 GAMMA=0.9 PHI=0.5)\0A\00"
@.str.7 = [75 x i8] c".MODEL MODELL NMOS (level=2 KP=28U VTO=0.7 LAMBDA=0.01 GAMMA=0.9 PHI=0.5)\0A\00"
@.str.8 = [28 x i8] c".PRINT OP iter(0) V(nodes)\0A\00"
@.str.9 = [5 x i8] c".op\0A\00"
@.str.10 = [15 x i8] c".options acct\0A\00"
@.str.11 = [6 x i8] c".end\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%10 = load i8**, i8*** %4
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 (i8*, i8*, ...) @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%14 = load i32, i32* %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %14)
store i32 1, i32* %6
br label %16
16: ; preds = %41, %2
%17 = load i32, i32* %6
%18 = load i32, i32* %5
%19 = icmp ule i32 %17, %18
br i1 %19, label %20, label %44
20: ; preds = %16
%21 = load i32, i32* %6
%22 = mul i32 %21, 2
%23 = sub i32 %22, 1
store i32 %23, i32* %7
%24 = load i32, i32* %6
%25 = mul i32 %24, 2
%26 = add i32 %25, 1
store i32 %26, i32* %8
%27 = load i32, i32* %6
%28 = mul i32 %27, 2
store i32 %28, i32* %9
%29 = load i32, i32* %6
%30 = load i32, i32* %9
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %30)
%32 = load i32, i32* %6
%33 = load i32, i32* %8
%34 = load i32, i32* %7
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %32, i32 %33, i32 %34, i32 0, i32 0)
%36 = load i32, i32* %6
%37 = load i32, i32* %9
%38 = load i32, i32* %9
%39 = load i32, i32* %8
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %36, i32 %37, i32 %38, i32 %39, i32 0)
br label %41
41: ; preds = %20
%42 = load i32, i32* %6
%43 = add i32 %42, 1
store i32 %43, i32* %6
br label %16
44: ; preds = %16
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.6, i64 0, i64 0))
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.7, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@.str.1 = [28 x i8] c"%u cascaded NMOS inverters\0A\00"
@.str.2 = [13 x i8] c"vd%u %u 0 5\0A\00"
@.str.3 = [38 x i8] c"md%u %u %u %u %u modeld w=10u l=2u\0A\00"
@.str.4 = [37 x i8] c"ml%u %u %u %u %u modell w=2u l=2u\0A\00"
@str = [11 x i8] c"vin 1 0 .8\00"
@str.12 = [74 x i8] c".MODEL MODELD NMOS (level=2 KP=28U VTO=0.7 LAMBDA=0.01 GAMMA=0.9 PHI=0.5)\00"
@str.13 = [74 x i8] c".MODEL MODELL NMOS (level=2 KP=28U VTO=0.7 LAMBDA=0.01 GAMMA=0.9 PHI=0.5)\00"
@str.14 = [27 x i8] c".PRINT OP iter(0) V(nodes)\00"
@str.15 = [4 x i8] c".op\00"
@str.16 = [14 x i8] c".options acct\00"
@str.17 = [5 x i8] c".end\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = call i32 (i8*, i8*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 0
br i1 %11, label %23, label %12
12: ; preds = %2, %12
%13 = phi i32 [ %20, %12 ], [ 1, %2 ]
%14 = shl i32 %13, 1
%15 = add i32 %14, -1
%16 = or i32 %14, 1
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %14)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %13, i32 %16, i32 %15, i32 0, i32 0)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %13, i32 %14, i32 %14, i32 %16, i32 0)
%20 = add i32 %13, 1
%21 = load i32, i32* %3
%22 = icmp ugt i32 %20, %21
br i1 %22, label %23, label %12
23: ; preds = %12, %2
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.12, i64 0, i64 0))
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.13, i64 0, i64 0))
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.14, i64 0, i64 0))
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.15, i64 0, i64 0))
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.16, i64 0, i64 0))
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.17, i64 0, i64 0))
ret void
}